標籤:css html 介面
最近在有學習了下css+html,利用css+html寫模仿寫下了搜狐布局的一部分
首先建立一個html檔案,命名為sohu.html
代碼如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>sohu.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="./sohu.css"> </head> <body> <!--最上面的div --> <div class="top"> <div class="login">登入部分</div> <div class="indexpage">設為首頁</div> <div class="myhref">超連結</div> </div> <!--logo div --> <div class="logo"><img src="sohu1.jpg"/></div> <div class="navi">導覽列</div> <!-- 廣告部分 --> <div class="ad"> <div class="stuad">招生廣告</div> <div class="ad2">廣告2</div> <div class="housead">房地產廣告</div> <div class="picad"> <table height="100%" aligin="center" valign="middle"> <tr> <td> <img src="car2.jpg"> </td> </tr> </table> </div> </div> </body></html>
在寫css檔案:
</pre><pre name="code" class="css">body{width:950px;/*高度定不下來不要寫,自己適應 */margin:0 auto;/* background-color: pink; */border:1px solid red;font-size: 12px;}.top{width:950px;height:22px;background-color: pink;}/*登入部分 */.login{width:416px;height:22px;background-color: green;float:left;}/*設為首頁 */.indexpage{width:105px;height:20px;background-color: gray;float:left;margin-left: 80px;}/* 超連結 */.myhref{width:250px;height:20px;float:right;background-color: #b4b4b4;}/* logo */.logo{width:137px;height:68px;float:left;background-color: yellow;margin-top: 5px;}.logo img{width:137px;}/*導覽列 */.navi{width:807px;height:68px;float:left;background-color: #7CE574;margin-top:5px;margin-left: 5px;}/*廣告部分 */.ad{width:950px;height:212px;background-color: pink;margin-top: 5px;float:left;border:1px solid silver;}/*學生廣告 */.stuad{width:126px;height:196px;background-color: #EC7E8C;float:left;margin:5px 0 0 5px;}/*廣告2 */.ad2{width:453px;height:196px;margin:5px 0 0 15px;background-color: #EC7E8C;float:left;}/* 房地產廣告 */.housead{height:196px;width:150px;background-color: #7CE574;margin:5px 0 0 12px;float:left;}/* 圖片廣告 */.picad{height:212px;width:180px;float:right;background-color: #7CE574;border-left: 1px solid silver;text-align: center;}運行後介面為:
本文原創,轉載請註明:http://blog.csdn.net/j903829182/article/details/38732321