DEV Community

Discussion on: Quick CSS Quiz #2

Collapse
 
ismail9k profile image
Abdelrahman Ismail

This is one of the CSS behaviors that can be awkward at first, but once you learn it, you will know how it's so powerful tool.
As you said you can use it to create perfect squares, even more you can create a fixed ratio between width and height for example, this is how you can create a responsive video base on this behavior:

.videoWrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    padding-top: 25px;
    height: 0;
}
.videoWrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}