What's new

Welcome to the forum 👋, Visitor

To access the forum content and all our services, you must register or log in to the forum. Becoming a member of the forum is completely free.

[TIPS] position: absolute CSS

Koyyiko

New member
Joined
Aug 22, 2022
Messages
17
Reaction score
0
HTML Coins
0
CSS position property comes of great use while positioning the elements on the web page. It comes with static, CSS sticky, absolute, relative, and fixed options. These values serve different purposes in defining the location of an element. Among them, position value absolute is something whose expertise will help you a lot in your web development career. It gives you more control over the elements and takes them out of the document’s normal flow.

An element with the position set as absolute can be positioned at a fixed location for all the situations you encounter in cross browser testing. However, the element will take the position relative to the first ancestor with the property set as absolute or relative. If no such element exists, the position takes reference from the root element, i.e., HTML.

The following code places two div boxes with one as position: absolute.

Code:
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Position Absolute</title>
  </head>
  <style>

  div.relative {
      position: relative;
      width: 300px;
      height: 250px;
      border: 2px solid #000000;
      }

  div.absolute {
      position: absolute;
      top: 70px;
      right: 10px;
      width: 150px;
      height: 80px;
      border: 2px solid #000000;
}
  </style>
  <body>

    <div class = "relative">My position is relative.

    <div class = "absolute">My position is absolute.</div>

  </div>

  </body>
</html>

The output is rendered as follows.

The output is rendered

Output on mobile.

Output on mobile

One important thing to remember is that the element with the position as absolute does not affect the other elements. It also does not affect any other element, which can create design issues later if you are not careful.
 

Theme customization system

You can customize some areas of the forum theme from this menu.

  • Wide/Narrow view

    You can control a structure that you can use to use your theme wide or narrow.

    Grid view forum list

    You can control the layout of the forum list in a grid or ordinary listing style structure.

    Picture grid mode

    You can control the structure where you can open/close images in the grid forum list.

    Close sidebar

    You can get rid of the crowded view in the forum by closing the sidebar.

    Fixed sidebar

    You can make it more useful and easier to access by pinning the sidebar.

    Close radius

    You can use the radius at the corners of the blocks according to your taste by closing/opening it.

  • Choose the color combination that reflects your taste
    Background images
    Color gradient backgrounds
Back