第三次编程

2017-01-31  本文已影响0人  星星yx

1.让三个DIV并排显示(三种方法实现)

第一种方法:inline-block
<!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>方法1</title>
<style>
div{
    width:100px;
    height:100px;
    color:black;
    background-color:red;
    display:inline-block;
    }
</style>
</head>

<body>
<div class="box">DIV</div>
<div class="box">DIV</div>
<div class="box">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>方法2</title>
<style>
div{
    width:100px;
    height:100px;
    background-color:red;
    color:black;
    float:left;
    margin:5px;
}
</style>
</head>

<body>
<div class="box1">DIV</div>
<div class="box2">DIV</div>
<div class="box3">DIV</div>
</body>
</html>
2.png
第三种方法:定位
<!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>方法3</title>
<style>
div{
    width:100px;
    height:100px;
    background-color:red;
    color:black;
}
.box2{
    position:relative;
    left:110px;
    bottom:100px;
}
.box3{
    position:relative;
    left:220px;
    bottom:200px;
}
</style>
</head>

<body>
<div class="box1">DIV1</div>
<div class="box2">DIV2</div>
<div class="box3">DIV3</div>
</body>
</html>
3.png

2.腾讯大学—列表页

<!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>作业2</title>
<style>
body div span dl dt dd{
    padding:0px;
    margin:0px;     /*清除默认样式*/
}
.list{
    padding:0px 20px;
    width:226px;      /*设置整体的宽度,高度有整体内容撑开*/
}
.tittle{
    background:url(icon-rank.png) no-repeat left bottom;
    padding:20px 0px 0px 30px;
}
#box{
    margin:0px;
    padding:0px;
    width:226px;
    height:34px;
    background:url(rank-tab-gray-bg.png) no-repeat left bottom;
}
a{
    text-decoration:none;
    color:#000;
}
.tittle1{
    margin:0px;
    margin-left:2px;
    padding:10px 27px;
    border:1px solid #cccccc;
    border-bottom:none;
    border-right:none;
    font-size:14px;
    line-height:24px;
}
.tittle2{
    margin:0px;
    margin-right:2px;
    padding:10px 27px;
    border:1px solid #cccccc;
    border-top:none;
    border-right:none;
    font-size:14px;
    line-height:24px;
}
.lb1{
    margin-top:15px;
    height:160px;
    width:226px;    
    background:url(1452663224623.jpg) no-repeat;
}
.lb2{
    margin-top:20px;
    height:160px;
    width:226px;
    background:url(1466672022953.jpg) no-repeat;
}
.lb3{
    margin-top:20px;
    height:160px;
    width:226px;
    background:url(1416453832912.png) no-repeat;    
}
.lb4{
    margin-top:20px;
    height:160px;
    width:226px;
    background:url(1445345193444.jpg) no-repeat;
}

.lb5{
    margin-top:20px;
    height:160px;
    width:226px;
    background:url(1403269947115.png) no-repeat;    
}        /*图片的5大板块*/
.xbt1{
    width:8px;
    height:26px;
    font:bold 9px/24px '微软雅黑';
    color:#FFF;
    padding:0px 6px;
    background:#e2291c;
    display:inline-block;
    position:relative;
    top:125px;  
}
.xbt2{
    width:8px;
    height:26px;
    font:bold 9px/24px '微软雅黑';
    color:#FFF;
    padding:0px 6px;
    background:#ec5a2e;
    display:inline-block;
    position:relative;
    top:125px;  
}
.xbt3{
    width:8px;
    height:26px;
    font:bold 9px/24px '微软雅黑';
    color:#FFF;
    padding:0px 6px;
    background:#f6a544;
    display:inline-block;
    position:relative;
    top:125px;  
}
.xbt4{
    width:8px;
    height:26px;
    font:bold 9px/24px '微软雅黑';
    color:#FFF;
    padding:0px 6px;
    background:#ec5a2e;
    display:inline-block;
    position:relative;
    top:125px;  
}
.xbt5{
    width:8px;
    height:26px;
    font:bold 9px/24px '微软雅黑';
    color:#FFF;
    padding:0px 6px;
    background:#f6a544;
    display:inline-block;
    position:relative;
    top:125px;  
 }     /*5个小序号的样式*/
.nr2{
    width:196px;
    height:26px;
    padding-left:10px;
    background:#0b1213;
    display:inline-block;
    position:relative;
    top:134px;
    opacity:0.5;    
}   /*小透明度的设置*/ 
.nr3{
    width:196px;
    height:26px;
    font:bold 12px/26px '微软雅黑';
    color:#FFF;
    display:inline-block;
    position:relative;
    left:30px;
    top:99px;  /*字体的设置,为了防止字体也有透明度,所以在此处加上这个*/
}
dt{
    height:20px;
    padding-left:6px;
    background:url(icon-rank-item.png) no-repeat;
    word-spacing:16px;
    font:12px/20px '微软黑体';
    color:#000000;
    overflow:hidden;
}
dd{
    height:10px;
}     /*为了设置列表中的空位*/
</style>
</head>
<body>
  <div class="list">
        <h2 class="tittle">排行榜</h2>
        <div id="box">
            <span class="tittle1"><a href="#">最热排行</a></span><span class="tittle2"><a href="#">最新上线</a></span>
        </div>
        <a href="#"><div class="lb1">
            <span class="xbt1">1</span><span class="nr2"></span><span class="nr3">张小龙:微信四大价值观</span>
        </div></a>
        <a href="#"><div class="lb2">
            <span class="xbt2">2</span><span class="nr2"></span><span class="nr3">刘超:互联网时代需要什么样的UX设计人才?</span>
        </div></a>
        <a href="#"><div class="lb3">
            <span class="xbt3">3</span><span class="nr2"></span><span class="nr3">马化腾:腾讯将专注于互联网的连接器</span>
        </div></a>
        <a href="#">
        <div class="lb4">
            <span class="xbt4">4</span><span class="nr2"></span><span class="nr3">IT领袖会圆桌会议:互联网下一个风口在哪儿</span>
        </div></a>
        <a href="#"><div class="lb5">
            <span class="xbt5">5</span><span class="nr2"></span><span class="nr3">微信支付对实体商业的价值几何?</span>
        </div></a>
    <a href="#"><dl>
        <dt>6 张小龙:小程序正式发布,开启移送应用新时代</dt>
        <dd></dd>
        <dt>7 马化腾:通向互联网未来的七个路标</dt>
        <dd></dd>
        <dt>8 马化腾:腾讯现在只做两件事</dt>
        <dd></dd>
        <dt>9 使用UE4制作VR内容的优化</dt>
        <dd></dd>
         <dt>10 何凌南:谣言在想什么?</dt>
        <dd></dd>
        </dl></a>
    </div>
</body>
</html>
123.png 1234.png

百度链接:http://pan.baidu.com/s/1kVLmrmn 密码:d8f9

上一篇 下一篇

猜你喜欢

热点阅读