Fixed Aspect Ratio Boxes in CSS


Maintain the aspect ratio of boxes as they scale.

Source Code

.aspect-ratio-4-3 {
    width: 100%;
    padding-top: 75%; /* 4:3 Aspect Ratio */
    position: relative;
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments