【HTML&CSS】搜狐頁面代碼編寫

来源:https://www.cnblogs.com/xiaofu007/archive/2018/10/28/9867796.html
-Advertisement-
Play Games

看完一整本書,結果寫不出什麼東西,按書上教程來,基本能把例子完成個七七八八,可是用padding還是margin完全整不清……,而且只要結構一複雜,元素就各種不受控制。 沒辦法 找來韓順平老師的視頻(沒錯,就是在網上不知道怎麼搞來的) 看完老師講完整個html&CSS部分2,終於把這個內容吃透了。 ...


<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>搜狐首頁</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="Shortcut Icon" href="./META-INF/images/souhulogo.png" />
    <link rel="stylesheet" href="./sohu.css">
</head>

<body>
    <div class="top">
        <div class="logo">
            <div class="logoimg">
                圖標
            </div>
            <div class="dapp">
                下載app
            </div>
        </div>
    </div>
    <div class="mast">
        <!-- 第一部分 -->
        <div class="sousuo">
            <div class="sousuo1">
                搜索1
            </div>
            <div class="sousuo2">
                搜索2
            </div>
        </div>
        <!-- 第二部分 -->
        <div class="toutiaolianjie">
            頭條鏈接
        </div>
        <!-- 第三部分 -->
        <div class="guanggaolan">
            <div class="guanggaolan1">
                廣告1
            </div>
            <div class="guanggaolan2">
                廣告2
            </div>
        </div>
        <!-- 第四部分 -->
        <div class="xinwen">
            <!-- 第四部分第一列  圖片新聞-->
            <div class="imgxinwen">
                <div class="bigimg">
                    大圖新聞
                </div>
                <!-- 小圖新聞 -->
                <div class="smallimg">
                    <table class="smallimgtable">
                        <tr>
                            <td>
                                <div class="smallimgall smallimg1">
                                    小圖標題新聞1
                                </div>
                            </td>
                            <td>
                                <div class="smallimgall smallimg2">
                                    小圖標題新聞2
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="smallimgall smallimg3">
                                    小圖標題新聞3
                                </div>
                            </td>
                            <td>
                                <div class="smallimgall smallimg4">
                                    小圖標題新聞4
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
                <!--  視頻標題欄 -->
                <div class="shipinbiaoti">
                    視頻標題欄
                </div>
                <!--  視頻 -->
                <div class="shipin1">
                    大視頻
                </div>
                <div class="leftnews1">
                    文字新聞
                </div>
                <div class="shipin2">
                    視頻2
                </div>
                <div class="leftnews2">
                    文字新聞2
                </div>
            </div>
            <!-- 第四部分第二列  中間部分文字新聞-->
            <div class="textxinwen">
                <div class="textnewsall textnews1">
                    新聞標題8條
                </div>
                <div class="textnewsall textnews2">
                    新聞標題6條
                </div>
                <div class="textnewsall textnews3">
                    新聞標題6條
                </div>
                <div class="textnewsall textnews4">
                    新聞標題6條
                </div>
                <div class="textnewsall textnews5">
                    新聞標題6條
                </div>
                <div class="textnewsall textnews6">
                    新聞標題1條
                </div>
            </div>
            <!-- 第四部分第三列 右側內容標題-->
            <div class="biaotilan">

                <div class="right1">
                    換一換廣告
                </div>
                <div class="right2">
                    圖片廣告
                </div>
                <div class="right3">
                    24小時熱文
                </div>
            </div>
        </div>
    </div>
    <!-- 第五部分 -->

    <script src="" async defer></script>
</body>

</html>

 

看完一整本書,結果寫不出什麼東西,按書上教程來,基本能把例子完成個七七八八,可是用padding還是margin完全整不清……,而且只要結構一複雜,元素就各種不受控制。

沒辦法 找來韓順平老師的視頻(沒錯,就是在網上不知道怎麼搞來的)

看完老師講完整個html&CSS部分2,終於把這個內容吃透了。

韓順平老師講課最後一個用例就是還原搜狐門戶網站的首頁HTML和css部分,雖然視頻中他的是n年前的網站頁面,蛋根本不妨礙我完成完成現在版本的搜狐頁面 。

 第一次看完視頻,寫的亂七八糟,很多東西擺不到應有的地方,沒辦法,在瀏覽器按f12鍵,查看人家的源代碼,發現很多東西用了ul和li的組合插入文字,圖片,而是原來HTML和css組合也沒這麼難,大神的代碼實現也是很平凡很淡。

很多收穫記手機上,回頭整理髮這裡。

我做出來的效果圖是這樣的:

代碼如下:

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>搜狐首頁</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="Shortcut Icon" href="./META-INF/images/souhulogo.png" />
    <link rel="stylesheet" href="./sohu.css">
</head>

<body>
    <div class="top">
        <div class="logo">
            <div class="logoimg">
                圖標
            </div>
            <div class="dapp">
                下載app
            </div>
        </div>
    </div>
    <div class="mast">
        <!-- 第一部分 -->
        <div class="sousuo">
            <div class="sousuo1">
                搜索1
            </div>
            <div class="sousuo2">
                搜索2
            </div>
        </div>
        <!-- 第二部分 -->
        <div class="toutiaolianjie">
            頭條鏈接
        </div>
        <!-- 第三部分 -->
        <div class="guanggaolan">
            <div class="guanggaolan1">
                廣告1
            </div>
            <div class="guanggaolan2">
                廣告2
            </div>
        </div>
        <!-- 第四部分 -->
        <div class="xinwen">
            <!-- 第四部分第一列  圖片新聞-->
            <div class="imgxinwen">
                <div class="bigimg">
                    大圖新聞
                </div>
                <!-- 小圖新聞 -->
                <div class="smallimg">
                    <table class="smallimgtable">
                        <tr>
                            <td>
                                <div class="smallimgall smallimg1">
                                    小圖標題新聞1
                                </div>
                            </td>
                            <td>
                                <div class="smallimgall smallimg2">
                                    小圖標題新聞2
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="smallimgall smallimg3">
                                    小圖標題新聞3
                                </div>
                            </td>
                            <td>
                                <div class="smallimgall smallimg4">
                                    小圖標題新聞4
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
                <!--  視頻標題欄 -->
                <div class="shipinbiaoti">
                    視頻標題欄
                </div>
                <!--  視頻 -->
                <div class="shipin1">
                    大視頻
                </div>
                <div class="leftnews1">
                    文字新聞
                </div>
                <div class="shipin2">
                    視頻2
                </div>
                <div class="leftnews2">
                    文字新聞2
                </div>
            </div>
            <!-- 第四部分第二列  中間部分文字新聞-->
            <div class="textxinwen">
                <div class="textnewsall textnews1">
                    新聞標題8條
                </div>
                <div class="textnewsall textnews2">
                    新聞標題6條
                </div>
                <div class="textnewsall textnews3">
                    新聞標題6條
                </div>
                <div class="textnewsall textnews4">
                    新聞標題6條
                </div>
                <div class="textnewsall textnews5">
                    新聞標題6條
                </div>
                <div class="textnewsall textnews6">
                    新聞標題1條
                </div>
            </div>
            <!-- 第四部分第三列 右側內容標題-->
            <div class="biaotilan">

                <div class="right1">
                    換一換廣告
                </div>
                <div class="right2">
                    圖片廣告
                </div>
                <div class="right3">
                    24小時熱文
                </div>
            </div>
        </div>
    </div>
    <!-- 第五部分 -->

    <script src="" async defer></script>
</body>

</html>

css(html文件和css文件放同一個目錄層下):

body {
  margin: 0 auto;
  border: 1px solid red;
}
.mast {
  margin: 0 auto;
  width: 1180px;
  background-color: rgb(88, 88, 88);
}
.top {
  background-color: #222222;
  height: 30px;
}

.logo {
  width: 1180px;
  margin: 0 auto;
  background-color: yellow;
}

/* 從這裡開始一律採用左/右浮動 */
.logoimg {
  float: left;
  width: 145px;
  height: 95px;
  background-color: #25c058;
}
.dapp {
  float: right;
  width: 160px;
  background-color: yellow;
}

.sousuo{
    float: right;
    width: 940px;
    height: 40px;
    background-color: #174b12;
    margin-top: 25px;
}
.sousuo1{
    float: left;
    width: 550px;
    height: 40px;
    background-color: rgb(0, 255, 98);
}
.sousuo2{
    float: right;
    width: 300px;
    height: 40px;
    background-color: rgb(10, 30, 92);
}

.toutiaolianjie{
    float: left;
    width: 1180px;
    height: 75px;
    background-color: #c9141d;
    margin-top: 26px;
}
.guanggaolan{
    float: left;
    width: 1180px;
    height: 100px;
    background-color: #DEE1EA;
    margin-top: 20px;
}

.guanggaolan1{
    float: left;
    width: 1030px;
    height: 100px;
    background-color: rgb(99, 75, 155);
}
.guanggaolan2{
    float: right;
    width: 144px;
    height: 100px;
    background-color: rgb(10, 30, 92);
}
.xinwen{
    float: left;
    width: 1180px;
    height: 1150px;
    background-color: rgb(71, 71, 71);
    margin-top: 20px;
}

.imgxinwen{
    float: left;
    width: 320px;
    height: 1120px;
    background-color: rgb(255, 123, 123);
}

.bigimg{
    float: left;
    width: 320px;
    height: 213px;
    background-color: rgb(251, 0, 0);
}

.smallimg{
    float: left;
    width: 320px;
    height: 320px;
    background-color: rgb(251, 0, 0);
    margin-top: 10px;
}

.smallimgtable{
    float: left;
    width: 320px;
    height: 320px;
    background-color: rgb(0, 153, 255);
}

.smallimgall{
    float: left;
    width: 155px;
    height: 155px;
    background-color: rgb(163, 163, 163);
}

.shipinbiaoti{
    float: left;
    width: 320px;
    height: 20px;
    background-color: rgb(163, 163, 163);
    margin-top: 30px;
}

.shipin1{
    float: left;
    width: 320px;
    height: 160px;
    background-color: rgb(123, 255, 0);
    margin-top: 12px;
}

.leftnews1{
    float: left;
    width: 320px;
    height: 70px;
    background-color: rgb(55, 0, 255);
    margin-top: 15px;
}
.shipin2{
    float: left;
    width: 320px;
    height: 104px;
    background-color: rgb(123, 255, 0);
    margin-top: 30px;
}

.leftnews2{
    float: left;
    width: 320px;
    height: 127px;
    background-color: rgb(230, 54, 186);
    margin-top: 15px;
}

.textxinwen{
    float: left;
    width: 440px;
    height: 1120px;
    background-color: rgb(30, 255, 49);
    margin-left: 25px;
}

.textnewsall{
    float: left;
    background-color: rgb(0, 202, 185);
}
.textnews1{
    float: left;
    width: 440px;
    height: 225px;
    background-color: rgb(0, 202, 185);
}
.textnews1,.textnews2,.textnews3,.textnews4,.textnews5{
    float: left;
    width: 440px;
    height: 180px;
    background-color: rgb(177, 106, 167);
    margin-top: 30px;
}

.textnews6{
    float: left;
    width: 440px;
    height: 20px;
    background-color: rgb(177, 106, 167);
    margin-top: 30px;
}

.biaotilan{
    float: right;
    width: 300px;
    height: 1120px;
    background-color: rgb(72, 52, 255);
}

.right1{
    float: left;
    width: 300px;
    height: 450px;
    background-color: rgb(217, 255, 0);
}

.right2{
    float: left;
    width: 300px;
    height: 250px;
    background-color: rgb(217, 255, 0);
    margin-top: 12px;
}
.right3{
    float: left;
    width: 300px;
    height: 414px;
    background-color: rgb(217, 255, 0);
    margin-top: 10px;
}

 腦袋要炸了,繼續完善!


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • Android json支持五種數據類型 String / int(float)/bool / null / object 今天說 object : ...
  • 歡迎大家前往 "騰訊雲+社區" ,獲取更多騰訊海量技術實踐乾貨哦~ 本文由 "elson" 發表於 "雲+社區專欄" 目前在不考慮IE以及低端安卓機(4.3 )的相容下,已經可以放心使用flex進行佈局了。什麼是flex佈局以及它的好處,這裡就不再贅述。 在這篇文章里,想說說flex佈局的屬性語法及 ...
  • 準備 工具:HBuilder 一、全屏設置,不顯示系統狀態欄 這裡所說的系統狀態欄就是包括了:信號、運營商、電量等信息手機屏幕最頂部信息。 全屏並非狀態欄透明或變色,而是沒有狀態欄,也就是看不見電量、信號那條了,部分項目需要這樣的場景。 全屏設置方法: 新建一個wap2app項目並完成各項配置後,打 ...
  • Android預設的Toast太醜了,我們來封裝一個花里胡哨的Toast吧,就叫ColoredToast。 Github:https://github.com/imcloudfloating/DesignApp 效果: Toast有一個setView方法,通過它我們可以設置自定義的佈局,這裡我只是加 ...
  • C/S架構(Client/Server,即客戶機/伺服器模式)分為客戶機和伺服器兩層:第一層是在客戶機系統上結合了表示與業務邏輯,第二層是通過網路結合了資料庫伺服器。簡單的說就是第一層是用戶表示層,第二層是資料庫層。客戶端和伺服器直接相連,這兩個組成部分都承擔著重要的角色。 Android內核是基於 ...
  • 前面已經封裝了很多常用、基礎的組件了: "base module" , 包括了: crash 處理 常用工具類 apk 升級處理 log 組件 logcat 採集 ftp 文件上傳 blur 高斯模糊 fresco 圖片處理 等等 那麼,今天繼續再來封裝一個網路組件,基於 "volley" 的二次封 ...
  • Application是Android的又一大組件,在App運行過程中,有且僅有一個Application對象貫穿應用的整個生命周期,所以適合在Application中保存應用運行時的全局變數。而開展該工作的基礎,是必須獲得Application對象的唯一實例,也就是將Application單例化。 ...
  • 元素分類: 1.行級元素:內聯元素 inline 特征:內容決定元素所占位置,不可以通過CSS改變寬高 span strong em a del 2.塊級元素:block特征:獨占一行,可以通過CSS改變寬高 div p ul li ol form address 3.行級塊元素:inline-bl ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...