html代码如下:
图片如下。。红色的部分是我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
何时用clear:看一看这篇: CSS浮动属性Float详解
何时用clear:看一看这篇: CSS浮动属性Float详解
3q,我去认真看下。。
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