I thought an inline-block element can start a new line and can be sized using the height and width properties however i am wrong? Is there some sort of error in the display and positioning quiz because you can start a new line with inline-block .
In the quiz, the correct answer is “does not start a new line and can be sized using the height and width properties.”
Also there is a question " Which of the following values will position an element in relation to the nearest non-static element?"
What does this actually mean? I know the answer is absolute but i don’t know why.
I just realised it does not start a new line, my bad however i still don’t understand the latter part to the question.
From Stack Overflow
not statically positioned element is an element having position
property set to anything other than static
(which is the default value).
For e.g: position: relative || absolute || fixed
If no such positioned ancestor is found, the absolute
positioned element will be positioned relative to the window"
From MDN:
The element is positioned relative to its closest positioned ancestor (if any) or to the initial containing block. Its final position is determined by the values of top
, right
, bottom
, and left
.
I read this as: If I position an element as absolute, its closest parent must be positioned as non-static, meaning, I need to declare position: _____;
on its parent element.
When I add:
}
position: absolute;
top: 20px;
left: 20px;
}
It will be moving relative to its parent.
You could create a HTML/CSS page to test it out, but it seems like you’re asking the right questions, and on the right track! Good luck!