Languages
[Edit]
EN

CSS - overlap two div elements

0 points
Created by:
Romany-Welsh
382

In this article, we would like to show you how to overlap two div elements using CSS.

Quick solution:

.internal-div {
   position:relative;
   top: 20px;
   left: 20px;
}

 

Practical example

In this example, we present how to create a style for internal div to make the overlapping effect.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>

    body {
      height: 150px;
    }

    div {
      height: 100px;
      width: 100px;
      background: DarkBlue;
    }

    .internal-div {
      background: DeepSkyBlue;
      opacity: 75%;

      /* required */
      position:relative;
      top: 20px;
      left: 20px;
    }

  </style>
</head>
<body>
  <div>
    <div class="internal-div"></div>
  </div>
</body>
</html>
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join