Positioning: Static, Relative, Absolute, Fixed, Sticky
Positioning: Static, Relative, Absolute, Fixed, Sticky
Positioning of different types of box models in HTML web page is controlled by applying position to the element using CSS. Different CSS box model positioning attributes in HTML web page provide you control over how and where to place web page content element information in the box model, where the web developer decides how to display web page elements in the web page and how to manipulate or control the existing web page elements with other elements. Here by default, you get five types of box model positioning. In which, static box model position, relative box model position, absolute box model position, fixed box model, and sticky box model, position are the major box model positions.
Static box model positioning in CSS.
CSS static box model positioning in HTML web page displays all the digital content in the web page by aligning it in the default positioning. This previews web elements in your web page as a normal document box. By default, static box model positioning in a web page has no significant effect on the top, bottom, left, and right box model attributes.
Static box model example in an HTML web page.
.boxmodel-static {
width: 300px;
height: 140px;
background-color: teal;
}
Relative box model positioning in CSS.
CSS Relative box model positioning in an HTML web page displays web elements in a document relative position in a box model document.
Whereas normally relative box model positioning will preview the top, bottom, left, and right box model properties in an offset order.
Relative box model example in an HTML web page.
.boxmodel-relative {
position: relative;
width: 400px;
height: 200px;
background-color: yellow;
top: 30px; /* it displays box model 20px down from top position */
left: 20px; /* it moves active box model 20px from left position to right direction */
}
Absolute box model positioning in CSS.
CSS Absolute Box Model Positioning Web page elements in an existing HTML web page are displayed at positions other than the nearest absolute position (static position) relative to the existing box model. While absolute box models preview in absolute position order with proper margins and alignment, sometimes absolute box models preview web page elements with exact dimensions. Absolute box model web page document display does not disturb or manipulate other elements.
Absolute box model example in an HTML web page.
.boxmodel-absolute {
position: absolute;
width: 200px;
height: 130px;
background-color: pink;
top: 70px; /* it moves 70px box model form top position */
left: 40px; /* it moves box model content 40px from the left direction */
}
Fixed box model positioning in CSS.
In the current HTML web page, CSS fixed box model positioning previews the web page element at a relative position to the viewport. So that, this fixed box model is displayed at the same place even when the web page is scrolled in the current web page.
Whereas in box model fixed position, it is removed from the normal web page document preview.
Continue Reading On — https://vcanhelpsu.com













