CSS重叠元素、层交互的定位与实现代码,三者交叉重叠,绝对定位的实现,我们通过这个例子,可以看到代码并不复杂,但是可以感受到css的灵活性,与早期的表格式网页相比,css更能设计出新颖的布局,如果您还没熟悉css,请参照烈火网提供的css手册。 演示: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>css重叠</title> <style> .sun{ position:absolute; width:150px; height:100px; background:#000000; z-index:10px; } .index1{ top:50px; left:50px; background:#333333; z-index:2; } .index2{ position:relative; top:100px; left:100px; background:#666666; z-index:-1; } .index3{ top:150px; left:150px; background:#999999; z-index:1; } div{ position:absolute; width:200px; height:150px; } </style> </head> <body> <div class="index1"></div> <div class="index2"></div> <div class="index3"> <div class="sun"></div></div> </body> </html> <br /><center>如不能显示效果,请按Ctrl+F5刷新本页,更多网页代码:<a href='http://www.veryhuo.com/' target='_blank'>http://www.veryhuo.com/</a></center>提示:可修改后代码再运行! 文章导航 CSS图文混排,Div左图右文的布局代码外框自适应内容高度的CSS实例代码