[HTML5]HTML結構性元素(Structure)


參考自:http://techbrood.com/h5b2a?p=html-structure

結構性元素用來組織文檔的各個部分

為了讓文檔層次分明,我們可以把文檔中的元素按其內容的作用進行組合,這就需要使用到一些HTML結構性元素。 共有4種HTML結構性元素(structural HTML elements)可以使用。

Header

header 通常是HTML文檔內容中的第一個元素,用來組織頁面頭部的內容,是對網站的介紹以及頁面導航,一般性包括標識(Logo)標語(Slogan)菜單(Menu)

header 也可以被用作某篇文章(article)或某個區塊(section)部分的頭部內容。

footer 通常是HTML文檔內容中的最后一個元素,包含網站一些次要的但是公共的(多個頁面共享)信息,比如常用快捷鏈接、網站版權聲明和備案信息等。

Main

main 元素包含當前頁面的主體內容,網站各個頁面可以共享header和footer這些通用元素,但main元素應該是彼此不同的。

Aside

aside 元素通常用來包含一些和當前頁面內容有關的額外信息,比如博客文章頁面的關聯評論、推薦文章列表等,一般以左右邊欄的形式呈現在頁面兩邊。

Article

article 元素通常用於組織圖文博客、論文和文章。

Section

section 元素的結構粒度要小一些,自身並不需要特別的語義,通常用來把一些相關的元素組合在一起。

 

下面是一個完整的示例(為了便於理解頁面結構的布局,里面包含了CSS樣式,可暫時忽略):

<!-- header begin -->
<header class="exp-header">
    <img class="logo" src="/uploads/151001/canon.png">
    <span>Techbrood is awesome :)</span>
    <div class="exp-menu"></div>
</header>
<!-- header end -->

<!-- main begin -->
<main class="exp-main">
    <!-- aside begin -->
    <aside class="comments">
        <h4>Latest comments</h4>
        <ul>
            <p>looks good</p>
            <p>i want more</p>
            <p>i have paid the awesome</p>
        </ul>
    </aside>
    <!-- aside end -->
    <article>
        <section class="intro">
            <h2>Introduction</h2>
            <p>
                Leading search engines on web creatives.
            </p>
            <ul>
                <li>HTML5</li>
                <li>CSS3</li>
                <li>WebGL</li>
                <li>SVG</li>
                <li>JavaScript/ES6</li>
            </ul>
            <h2>Description</h2>
            <p>
                We collect funny front-end works and tuturials from all over the world openning websites, and further we provide localization/indexing/tagging/deploying/online debugging services for these free resources.
                <a href="techbrood.com">techbrood.com</a>, we hope it help promoting the usage of new html5 techniques.
            </p>
            <ol>
                <li>techbrood.com</li>
                <li>wow.techbrood.com</li>
            </ol>
        </section>
        <section class="references">
            <h2>References</h2>
            <ol>
                <li><cite><a href="#">google.com</a></cite>, Google</li>
                <li><cite><a href="#">github.com</a></cite>, Github</li>
            </ol>
        </section>
    </article>
</main>
<!-- main end -->

<!-- footer begin -->
<footer class="exp-footer">
    <div>Copyright © 2015 TechBrood Co.</div>
    <div>滬ICP備14011478號</div>
</footer>
<!-- footer end -->

 

.exp-header,
.exp-footer {
    -webkit-transition-duration: 0.25s;
    transition-duration: 0.25s;
    -webkit-transition-delay: 0.25s;
    transition-delay: 0.25s;
    height: 9vh;
    z-index: 2;
    font-size: 120%;
    color: white;
    font-weight: 700;
}
.exp-header {
    background-color: #5d6373;
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;
    line-height: 9vh;
    padding-left: 1.5rem;
}
.exp-footer {
    width: 100%;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -webkit-flex-direction: row;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
}
.exp-menu {
    position: absolute;
    top: 0;
    right: 25px;
    height: 9vh;
    width: 9vh;
    background-color: #454b5b;
    box-shadow: 0 0 1rem rgba(0, 0, 0, 0.4);
}
.exp-menu:before {
    content: '';
    width: 1.3rem;
    height: 0.25vh;
    position: absolute;
    background-color: white;
    top: calc(9vh / 2 - 0.5rem);
    left: calc(9vh / 2 - 0.75rem);
    box-shadow: 0.25rem 0.5rem 0 white, 0 1rem 0 white;
}
.exp-footer {
    background-color: #252a37;
    position: fixed;
    width: 100%;
    bottom: 0;
    left: 0;
}
.exp-main {
    margin: 20px 0;
    width: 100%;
}
body {
    margin: 0;
    padding: 0;
}
.logo {
    position: relative;
    top: 8px;
}
aside {
    width: 25%;
    float: left;
    margin-left: 68.02721%;
    margin-right: -100%;
    padding-top: 20px;
    padding-bottom: 60px;
    margin-top: 40px;
    padding-left: 20px;
    color: #2f2a2a;
}
article {
    width: 60%;
    float: left;
    margin-left: 8.5034%;
    margin-right: -100%;
    padding-top: 20px;
    border-right: 1px dashed #666;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM