re: Quick CSS Quiz #2 VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I know that padding is always calculated from the width but I can't say why, there is no real reason in the specs. I just knew the answer because...
 

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%;
}
code of conduct - report abuse