How does the padding work in responsive CSS square? -


i learning how develop responsive liquid css designs , came across technique, block display elements (eg. div) have % dimensions. in order display them, following css code used:

.class:before {     content: "";     display: block;     padding-top: 100%; } 

my confusion comes padding property. far know, in css box model (css2), padding affects inner part of block element, not outer. in technique used, without it, element not visible. explain me in terms of box model, padding property here?

in case explanation confusing, attaching 2 links working examples:

http://www.mademyday.de/css-height-equals-width-with-pure-css.html

http://jsfiddle.net/josedvq/38tnx/

alexander.

css pseudo element ::before (:before) or ::after (:after) + content property, creates child element inside container.

and a percentage padding value relative width of container - w3c spec, padding-top:100% + display:block creates square.

.square {      width: 10%;      background: blue;  }  .square:before {      content: "";      display: block;      padding-top: 100%;  }
<div class="square"></div>


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -