An element with position: ________ is positioned based on the viewport and stays fixed when scrolling.
- static
- relative
- absolute
- fixed
The correct option is fixed. When an element has a position: fixed, it is positioned relative to the viewport and remains fixed in its position even when the user scrolls the page.
Loading...
Related Quiz
- How does the font-weight property affect the appearance of text?
- How does the use of custom fonts affect the loading time of a web page?
- A developer wants a sidebar to be fixed on the desktop but static on mobile devices. Which CSS properties and values will they need to adjust using media queries?
- What is the default value of the flex-direction property in a Flexbox container?
- Which pseudo-class would you use to style an element that is being hovered over by a mouse pointer?