oursolutionarchitectoursolutionarchitect
  • Selected Reading
  • Q&A

CSS Flexbox (Flexible Box)


The Flexible Box Layout Module, makes it easier to design flexible responsive layout structure without using float or positioning. Browser Support.

CSS Flexible Box Layout, commonly known as Flexbox, is a CSS web layout model. It is in the W3C's candidate recommendation stage. The flex layout allows responsive elements within a container to be automatically arranged depending on viewport size.

The CSS Flexbox Container Properties ; flex-wrap, Specifies whether the flex items should wrap or not, if there is not enough room for them on one flex line.

Flexbox is a layout mechanism designed for laying out groups of items in one dimension. Learn how to use it in this module.

You can use two values top and left along with the position property to move an HTML element anywhere in the HTML document.

  • Move Left - Use a negative value for left.
  • Move Right - Use a positive value for left.
  • Move Up - Use a negative value for top.
  • Move Down - Use a positive value for top.

NOTE − You can use bottom or right values as well in the same way as top and left.

Here is the example −

<html>
   <head>
   </head>

   <body>
      <div style = "position:relative; left:80px; top:2px; background-color:yellow;">
         This div has relative positioning.
      </div>
   </body>
</html>

It will produce the following result −

Absolute Positioning

An element with position: absolute is positioned at the specified coordinates relative to your screen top-left corner.

You can use two values top and left along with the position property to move an HTML element anywhere in the HTML document.

  • Move Left - Use a negative value for left.
  • Move Right - Use a positive value for left.
  • Move Up - Use a negative value for top.
  • Move Down - Use a positive value for top.

NOTE − You can use bottom or right values as well in the same way as top and left.

Here is an example −

<html>
   <head>
   </head>

   <body>
      <div style = "position:absolute; left:80px; top:20px; background-color:yellow;">
         This div has absolute positioning.
      </div>
   </body>
</html> 

Fixed Positioning

Fixed positioning allows you to fix the position of an element to a particular spot on the page, regardless of scrolling. Specified coordinates will be relative to the browser window.

You can use two values top and left along with the position property to move an HTML element anywhere in the HTML document.

  • Move Left - Use a negative value for left.
  • Move Right - Use a positive value for left.
  • Move Up - Use a negative value for top.
  • Move Down - Use a positive value for top.

NOTE − You can use bottom or right values as well in the same way as top and left.

Here is an example −

<html>
   <head>
   </head>

   <body>
      <div style = "position:fixed; left:80px; top:20px; background-color:yellow;">
         This div has fixed positioning.
      </div>
   </body>
</html>