H153 - Practice Quiz Week 6
- How are
widthandheightinterpreted in CSS-compliant browsers? Briefly describe how these two properties relate to other element box properties in the layout of a block-level element.Width and height of the content area. Padding, borders and margins are added to this area.
- What do the "offset properties" define in the context of absolute (and fixed) positioning?
How far the element is offset from the analgous side of the containing block.
- Consider the following:
div#contain {position: relative; width: 300px; height: 300px;}
div#contain img {position: absolute; height: 50px; width: 80px;}
Assume that there is only one image in the "container"div. Without changing the provided styles, center the image within its containing block using only offset properties. Then create a different answer where all of the offset properties are set to 0, but the image is still centered within its containing block. (Semi-hint:text-alignis a part of neither answer.)div#contain img {position: absolute; height: 50px; width: 80px; top: 125; bottom: 125; right: 110; left: 110;}
div#contain img {position: absolute; height: 50px; width: 80px; top: 0; bottom: 0; right: 0; left: 0; margin-top: 125px; margin-left: 110px;}
- Consider the following:
div#contain {position: relative; width: 300px; height: 300px;}
div#contain p {position: absolute; width: 10em; height: auto;}
Assume that there is only onepelement in the "container"div. Without changing the provided styles, place thepelement so that it is horizontally centered within the containing block. Then create a different answer where thepelement is just outside the containing block on the right side, where the right edge of the containing block just touches the left edge of the positioned paragraph.div#contain p {position: absolute; width: 10em; height: auto; left: 145;}
div#contain p {position: absolute; width: 10em; height: auto; margin: 0 auto;}
div#contain p {position: absolute; width: 10em; height: auto; left: 300;}
div#contain p {position: absolute; width; 10em; height: auto; left: 100%;}
- Consider the previous question. Is it possible to vertically center the
pelement inside its containing block without changing any of the given declarations?No, because we don't know how tall the p element is.