1、現象
<!DOCTYPE html > <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>重疊DIV</title> <style> .left{width:200px; float:left; color:#F00; border:1px solid #F00} .nofloat{width:100px; background:#CCC} </style> </head> <body> <div class="left">left對象DIV內</div> <div class="nofloat">nofloat對象DIV內</div> </body> </html>
2原因分析
class=left的div盒子使用了浮動屬性float:left,而class=nofloat未使用。這樣一個浮動DIV,一個未使用float浮動屬性,所以就造成重疊現象。
3、解決方法
(1)清除樣式
(2)2個都用浮動,或者都不用。