网站地图    收藏   

主页 > 前端 > css教程 >

div+css布局(一) - html/css语言栏目:html.css - 自学

来源:自学PHP网    时间:2015-04-14 14:51 作者: 阅读:

[导读] 最近写了一些布局的代码,出于工作效率的提升,我准备把这些代码都共享出来,然后在后期不断的完善,最终是的这些代码都模板化,所以希望大家不吝赐教。谢谢[html]!DOCTYPE html P...

    最近写了一些布局的代码,出于工作效率的提升,我准备把这些代码都共享出来,然后在后期不断的完善,最终是的这些代码都模板化,所以希望大家不吝赐教。谢谢

   

[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> 
</head> 
 
<body> 
<div style="width:950px; height:600px; color:#999999; margin:0px; padding:0px;float:left;"> 
<div style="width:950px;height:100px;"> 
<IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654194.jpg" ></div> 
<div style="margin-left:0px; float:left;"> 
    <div style="margin-left:0px; width:323; height:153; border:0px;float:left;"> 
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654422.jpg" /></div> 
    <div style="margin-left:0px; width:323; height:153; border:0px;float:left;"> 
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654455.jpg" /></div> 
    <div style="margin-left:0px; width:323; height:153; border:0px;float:left;"> 
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654313.jpg" /></div> 
    <div style="margin-left:0px; width:323; height:153; border:0px;float:left;"> 
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654389.jpg" /></div> 
    <div style="margin-left:0px; width:323; height:153; border:0px;float:left;"> 
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654394.jpg" /></div> 
</div> 
<div style="margin-left:0px; float:left;"> 
    <div style="margin-left:0px; width:291; height:142; border:0px;float:left;"> 
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654793.jpg" /></div> 
    <div style="margin-left:0px; width:254; height:142; border:0px;float:left;"> 
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654876.jpg" /></div> 
    <div style="margin-left:0px; width:133; height:142; border:0px;float:left;"> 
   <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654463.jpg" /></div> 
    <div style="margin-left:0px; width:272; height:142; border:0px;float:left;"> 
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654608.jpg" /></div> 
</div> 
<div style="margin-left:0px; float:left;"> 
     <div style="margin-left:0px; width:192; height:202; border:0px;float:left;"> 
     <div style="margin-left:0px; margin-top:0px "> 
     <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654563.jpg" /> 
     </div> 
     <div style="margin-left:0px; margin-top:0px"> 
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654549.jpg" /> 
     </div> 
     </div> 
    <div style="margin-left:0px; width:301; height:202; border:0px;float:left;"> 
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654213.jpg" width=301 height=202/></div> 
    <div style="margin-left:0px; width:144; height:202; border:0px;float:left;"> 
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654794.jpg" width=144 height=202/></div> 
    <div style="margin-left:0px; width:83; height:202; border:0px;float:left;"> 
   <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654971.jpg" width=83 height=202/></div> 
    <div style="margin-left:0px; width:228; height:202; border:0px;float:left;"> 
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654395.jpg" width=228 height=202/></div> 
</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>
</head>

<body>
<div style="width:950px; height:600px; color:#999999; margin:0px; padding:0px;float:left;">
<div style="width:950px;height:100px;">
<IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654194.jpg" ></div>
<div style="margin-left:0px; float:left;">
    <div style="margin-left:0px; width:323; height:153; border:0px;float:left;">
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654422.jpg" /></div>
    <div style="margin-left:0px; width:323; height:153; border:0px;float:left;">
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654455.jpg" /></div>
    <div style="margin-left:0px; width:323; height:153; border:0px;float:left;">
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654313.jpg" /></div>
    <div style="margin-left:0px; width:323; height:153; border:0px;float:left;">
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654389.jpg" /></div>
    <div style="margin-left:0px; width:323; height:153; border:0px;float:left;">
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654394.jpg" /></div>
</div>
<div style="margin-left:0px; float:left;">
    <div style="margin-left:0px; width:291; height:142; border:0px;float:left;">
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654793.jpg" /></div>
    <div style="margin-left:0px; width:254; height:142; border:0px;float:left;">
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654876.jpg" /></div>
    <div style="margin-left:0px; width:133; height:142; border:0px;float:left;">
   <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654463.jpg" /></div>
    <div style="margin-left:0px; width:272; height:142; border:0px;float:left;">
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654608.jpg" /></div>
</div>
<div style="margin-left:0px; float:left;">
  <div style="margin-left:0px; width:192; height:202; border:0px;float:left;">
     <div style="margin-left:0px; margin-top:0px ">
     <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654563.jpg" />
     </div>
     <div style="margin-left:0px; margin-top:0px">
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654549.jpg" />
     </div>
     </div>
    <div style="margin-left:0px; width:301; height:202; border:0px;float:left;">
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654213.jpg" width=301 height=202/></div>
    <div style="margin-left:0px; width:144; height:202; border:0px;float:left;">
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654794.jpg" width=144 height=202/></div>
    <div style="margin-left:0px; width:83; height:202; border:0px;float:left;">
   <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654971.jpg" width=83 height=202/></div>
    <div style="margin-left:0px; width:228; height:202; border:0px;float:left;">
    <IMG alt="" src=http://up.2cto.com/2013/0419/20130419012654395.jpg" width=228 height=202/></div>
</div>
</div>
</body>


</html>

       之前我将这些图片是用<img/><img/>的格式排列的,发现这个元素之间总是存在3个像素左右的间隔,及时使用了margin-left:0; 也不能改变这种状态。后来在<img/>两侧都加了,<div></div>元素之后这种情况解决了。  总结:可使用<div></div>做无缝排列。

 

       下面是效果图:

 \

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论