Z Index Layers

Z Index Layers

Hard CSS Box Model & Sizing 27 views
Explanation Complexity

Problem Statement

Create two overlapping boxes and bring one on top using z-index.

Input Format

No input.

Output Format

Print the HTML+CSS code in one block.

Constraints

Use position and z-index on both boxes.

Input / Output Format

Input Format
No input.
Output Format
Print the HTML+CSS code in one block.
Constraints
Use position and z-index on both boxes.

Examples

Input:
Output:
(HTML+CSS code)

Example Solution (Public)

CSS
<!doctype html>
<html lang='en'>
<head>
  <meta charset='utf-8'>
  <meta name='viewport' content='width=device-width, initial-scale=1'>
  <title>meetcode</title>
  <style>
    .stage { position: relative; height: 140px; }
    .a, .b { position: absolute; width: 180px; height: 90px; padding: 10px; color: #fff; border-radius: 12px; }
    .a { background: #0b5; left: 20px; top: 20px; z-index: 1; }
    .b { background: #1b263b; left: 60px; top: 50px; z-index: 2; }
  </style>
</head>
<body>
  <div class='stage'>
    <div class='a'>meetcode A</div>
    <div class='b'>meetcode B</div>
  </div>
</body>
</html>

Official Solution Code

<!doctype html>
<html lang='en'>
<head>
  <meta charset='utf-8'>
  <meta name='viewport' content='width=device-width, initial-scale=1'>
  <title>meetcode</title>
  <style>
    .stage { position: relative; height: 140px; }
    .a, .b { position: absolute; width: 180px; height: 90px; padding: 10px; color: #fff; border-radius: 12px; }
    .a { background: #0b5; left: 20px; top: 20px; z-index: 1; }
    .b { background: #1b263b; left: 60px; top: 50px; z-index: 2; }
  </style>
</head>
<body>
  <div class='stage'>
    <div class='a'>meetcode A</div>
    <div class='b'>meetcode B</div>
  </div>
</body>
</html>
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.