日期:2014-05-16  浏览次数:20618 次

为什么我添加的那条线跑到顶端去了
<!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" />
<style type="text/css">
img[title~="Figure"]
{
float: left;
border: 1px solid gray;
}
img.i1
{
float: left;
clear: both;
}
img.i2
{
float: left;
clear: both;
}
</style>
</head>

<body>
      <h1>可以应用样式</h1>
      <img title="Figure 1" src="http://www.w3school.com.cn/i/figure-1.gif" />
      <img title="Figure 2" src="http://www.w3school.com.cn/i/figure-2.gif" />
      
      <hr />

      <img class="i1" src="http://www.w3school.com.cn/i/figure-1.gif" />
      <img class="i2" src="http://www.w3school.com.cn/i/figure-2.gif" />
</body>
</html>


------解决方案--------------------
hr要清楚浮动,要不会会一起浮动


      <hr style="clear:both" />
------解决方案--------------------
空白边和浮动元素叠加了,另外用个元素来清楚浮动

<!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" />
<style type="text/css">
img[title~="Figure"]
{
    float: left;
    border: 1px solid gray;
}
img.i1
{
    float: left;