- Key Points:
- Code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> div{ position: relative; } p{ width: 50px; height: 50px; background: red; opacity: 0.5; position: absolute; z-index: 999; top: 0; left: 0; } </style> </head> <body> <h3>外部元素</h3> <h3>外部元素</h3> <h3>外部元素</h3> <div> <h3>内部元素</h3> <h3>内部元素</h3> <h3>内部元素</h3> <p></p> </div> </body> </html>
- Effect:
css relative positioning does not take up space
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325345087&siteId=291194637
Recommended
Ranking