Home >Web Front-end >HTML Tutorial >The style is still wrong after the html is cleared of floats. . How to break, solve_html/css_WEB-ITnose
html代码如下:
f8fda4d24e0780c4e3a78be9728ee2c3
253a6235234450c0aaa9bfc76d2b0259
01563355710f8fa774a5f8e250b277ef
25edfb22a4f469ecb59f1190150159c6夜空中最亮的星 |bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6送别 |bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6没有什么不同 |bed06894275b65c1ab86501b08a632eb
929d1f5ca49e04fdcb27f9465b944689
16b28748ea4df4d9c2150843fecfba68
3fdb52410d66661a276572c7ea58611b
01563355710f8fa774a5f8e250b277ef
25edfb22a4f469ecb59f1190150159c61628e1ab6e9d2e3569950bcdb3dbc304bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c66be67fc026203ce4ac4a80a8c15196abbed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c68d5374b215d36b37c7f04749a56b7f94bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6bfa4014b6a758e384090695f76ed83b9bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6029b286ddafda8a3ff86ddaf0ab7af00bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6d02776a92359f4185cad780bfef97145bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6fbdd6bed31abfb536d130a03570fe310bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6e949eb4ea6e3447dbdfb7955d0853140bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6db04e34b4a1a9bf385ddd9cdb50252cfbed06894275b65c1ab86501b08a632eb
929d1f5ca49e04fdcb27f9465b944689
16b28748ea4df4d9c2150843fecfba68
16b28748ea4df4d9c2150843fecfba68
css样式代码如下:
.right{
float:right;
}
.right .top{
width:750px;
height:60px;
line-height:60px;
border:2px solid #F66;
margin-bottom:15px;
}
.top ul{
padding-left:15px;
}
.top ul li{
float:left;
width:240px;
margin-bottom:15px;
border:1px solid #3CC;
}
.right .bott{
width:750px;
border:2px dashed #F3C;
padding-top:20px;
}
.bott ul{
margin-bottom:20px;
}
.bott ul li{
float:left;
margin-bottom:20px;
margin-left:20px;
height:220px;
width:220px;
}
.bott ul li img{
width:220px;
height:220px;
}
.footer{
margin:auto 30px;
background:#3F6;
}
.clearfix:after{
content".";
display:block;
height:0px;
clear:both;
visibility:hidden;
显示的结果是我右边部分的框压根就没有框住所有的li。。。图片传不上。。郁闷
图片如下。。红色的部分是我right部分的边框,本来是要套住所有li的哪个图片的。。
我觉得应该是清除浮动的关系,可是我都清浮动了,,为什么还是没有效果呢。。坐等解决啊
<!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><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">.right{float:right;}.right .top{width:750px;height:60px;line-height:60px;border:2px solid #F66;margin-bottom:15px;}.top ul{padding-left:15px;}.top ul li{float:left;width:240px;margin-bottom:15px;border:1px solid #3CC;}.bott{float:left;width:750px;border:2px dashed #F3C;}.bott ul{float:left;margin:0;padding:0;list-style:none;background-color:#f00;}.bott li{float:left;margin:0;padding:10px;height:220px;width:220px;background-color:#ddd;}.bott li img{width:220px;height:220px;background-color:#fff;border:1px solid #ccc;display:block;}.footer{margin:auto 30px;background:#3F6;}.clearfix:after{content".";display:block;height:0px;clear:both;visibility:hidden;}</style></head><body><div class="right clearfix"> <div class="top"> <ul class="clearfix"> <li>夜空中最亮的星 |</li> <li>送别 |</li> <li>没有什么不同 |</li> </ul> </div> <div class="bott"> <ul> <li><img src="img/1.jpg" alt="tup1"></li> <li><img src="img/2.jpg" alt="tup2"></li> <li><img src="img/3.jpg" alt="tup3"></li> <li><img src="img/4.jpg" alt="tup4"></li> <li><img src="img/5.jpg" alt="tup5"></li> <li><img src="img/6.jpg" alt="tup6"></li> <li><img src="img/7.jpg" alt="tup7"></li> <li><img src="img/10.jpg" alt="tup10"></li> <li><img src="img/15.jpg" alt="tup15"></li> </ul> </div></div></body></html>
<!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><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">.right{float:right;}.right .top{width:750px;height:60px;line-height:60px;border:2px solid #F66;margin-bottom:15px;}.top ul{padding-left:15px;}.top ul li{float:left;width:240px;margin-bottom:15px;border:1px solid #3CC;}.bott{float:left;width:750px;border:2px dashed #F3C;}.bott ul{float:left;margin:0;padding:0;list-style:none;background-color:#f00;}.bott li{float:left;margin:0;padding:10px;height:220px;width:220px;background-color:#ddd;}.bott li img{width:220px;height:220px;background-color:#fff;border:1px solid #ccc;display:block;}.footer{margin:auto 30px;background:#3F6;}.clearfix:after{content".";display:block;height:0px;clear:both;visibility:hidden;}</style></head><body><div class="right clearfix"> <div class="top"> <ul class="clearfix"> <li>夜空中最亮的星 |</li> <li>送别 |</li> <li>没有什么不同 |</li> </ul> </div> <div class="bott"> <ul> <li><img src="img/1.jpg" alt="tup1"></li> <li><img src="img/2.jpg" alt="tup2"></li> <li><img src="img/3.jpg" alt="tup3"></li> <li><img src="img/4.jpg" alt="tup4"></li> <li><img src="img/5.jpg" alt="tup5"></li> <li><img src="img/6.jpg" alt="tup6"></li> <li><img src="img/7.jpg" alt="tup7"></li> <li><img src="img/10.jpg" alt="tup10"></li> <li><img src="img/15.jpg" alt="tup15"></li> </ul> </div></div></body></html>
你装个代码比较软件看一看,我改动的css挺多的,删除了元素上的clearfix
你装个代码比较软件看一看,我改动的css挺多的,删除了元素上的clearfix
我试试。。能说下你发现我这代码的主要问题是哪些呢。。clearfix用的地方不对吗
你装个代码比较软件看一看,我改动的css挺多的,删除了元素上的clearfix
我试试。。能说下你发现我这代码的主要问题是哪些呢。。clearfix用的地方不对吗
不要在ul,上用margin,padding
9de57b0a0b653aaacd6be5c2ded43060
ff6d136ddc5fdfeffaf53ff6ee95f185
25edfb22a4f469ecb59f1190150159c61628e1ab6e9d2e3569950bcdb3dbc304bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c66be67fc026203ce4ac4a80a8c15196abbed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c68d5374b215d36b37c7f04749a56b7f94bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6bfa4014b6a758e384090695f76ed83b9bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6029b286ddafda8a3ff86ddaf0ab7af00bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6d02776a92359f4185cad780bfef97145bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6fbdd6bed31abfb536d130a03570fe310bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6e949eb4ea6e3447dbdfb7955d0853140bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6db04e34b4a1a9bf385ddd9cdb50252cfbed06894275b65c1ab86501b08a632eb
929d1f5ca49e04fdcb27f9465b944689
b67dc49803e99be143d093d6b5f2f02b
519e184c3e3c9e9d2446fd6b8ee4047116b28748ea4df4d9c2150843fecfba68
16b28748ea4df4d9c2150843fecfba68
何时用clear:看一看这篇: CSS浮动属性Float详解
何时用clear:看一看这篇: CSS浮动属性Float详解
3q,我去认真看下。。
9de57b0a0b653aaacd6be5c2ded43060
ff6d136ddc5fdfeffaf53ff6ee95f185
25edfb22a4f469ecb59f1190150159c61628e1ab6e9d2e3569950bcdb3dbc304bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c66be67fc026203ce4ac4a80a8c15196abbed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c68d5374b215d36b37c7f04749a56b7f94bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6bfa4014b6a758e384090695f76ed83b9bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6029b286ddafda8a3ff86ddaf0ab7af00bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6d02776a92359f4185cad780bfef97145bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6fbdd6bed31abfb536d130a03570fe310bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6e949eb4ea6e3447dbdfb7955d0853140bed06894275b65c1ab86501b08a632eb
25edfb22a4f469ecb59f1190150159c6db04e34b4a1a9bf385ddd9cdb50252cfbed06894275b65c1ab86501b08a632eb
929d1f5ca49e04fdcb27f9465b944689
b67dc49803e99be143d093d6b5f2f02b
519e184c3e3c9e9d2446fd6b8ee4047116b28748ea4df4d9c2150843fecfba68
16b28748ea4df4d9c2150843fecfba68
I have also tried this, no change. .
When you want the child box to float, it is best to set the parent box to float so that they are at the same level, so that the size of the parent box will change accordingly.
.clearfix:after{
content".";
display:block;
height:0px;
clear:both;
visibility:hidden;
It’s you Is the post incomplete, or is this what you wrote?
Let me say two things about this
One is irrelevant }
Two, your content is wrong
content: ".";
I tried it and it worked fine. You can try again.
The code is yours.
No: What editor is yours? I don’t want to highlight such low-level errors.
No: What editor do you have? You don’t even highlight such low-level errors
It’s just me being careless. . I use Dreamweaver
When you want the child box to float, it is best to set the parent box to float so that they are at the same level, so that the size of the parent box will change accordingly,
That makes sense. . . I learned a trick, thank you very much