- 要点:
- 代码:
<!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>
- 效果:
css相对定位不占用空间
猜你喜欢
转载自blog.51cto.com/12173069/2113281
今日推荐
周排行