By using the property position
with value fixed
.
As mentioned in the comments, you can use the position
property as follows:
<div class="componentA">test</div>
.componentA {
position: fixed; // we make it position relative to the viewport.
top:0; // top edge of content box to top position 0
right:0; // right edge of content box to right position 0
bottom:0; // bottom edge of content box to bottom position 0
left:0; // left edge of content box to left position 0
}
As you can see, we have now ruled that the content box edges of the div with class componentA to be positioned at the zero points (top, right, bottom, left) of the viewport. If that makes sense.
about position:fixed; ( from w3school )
An element with position: fixed;
is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled. The top, right, bottom, and left properties are used to position the element.
viewport ( from this answer )
The viewport is the part of the webpage that the user can currently see. The scrollbars move the viewport to show other parts of the page.
To be more specific, the viewport has nothing to do with screen resolution or the size of your browser window; it only refers to the space in which the webpage is visible to the user at any given time.