CSS——讀書筆記-06-列表&導航條-2

第六章 對列表應用樣式和建立導航條-2html

 

4.下拉菜單htm

<ul class="nav">
    <li><a jref="/home/">Home</a></li>
    <li><a jref="/product/">Product</a></li>
        <ul>
            <li><a href="/products/silverback/">Sliverback</a></li>
            <li><a href="/products/fontdeck/">Font Deck</a></li>
        </ul>
    <li><a jref="/services/">Services</a></li>
        <ul>
            <li><a href="/services/design/">Sliverback</a></li>
            <li><a href="/services/development/">Development</a></li>
            <li><a href="/services/consultancy/">Consultancy</a></li>
        </ul>
    <li><a jref="/contact/">Contact us</a></li>
</ul>

樣式:blog

》》設置外層樣式it

ul.nav, ul.nav ul {
    margin: 0;
    padding: 0;
    list-style-type: none;
    float: left;
    border: 1px solid #486B02;
    background-color: #8BD400;
}

ul.nav li {
    float: left;
    width: 8em;
    background-color: #8BD400;
}

》》設置默認隱藏io

ul.nav li ul {
    width: 8em;
    position: absolute;
    left: -999em;
}

》》設置劃過期顯示ast

.nav li:hover ul {
     left: auto;
}

》》設置單個菜單樣式class

ul.nav a {
    display: block;
    color: #2B3F00;
    text-decoration: none;
    padding: 0.3em 1em;
    border-right: 1px solid #486B02;
    border-left: 1px solid #E4FFD3;
}

ul.nav li li a {
    border-top: 1px solid #E4FFD3;
    border-bottom: 1px solid #486B02;
    border-left: 0;
    border-right: 0;
}

ul.nav li:last-child a {
    border-right: 0;
    border-bottom: 0;
}

ul a:hover,
ul a:focus {
    color: #E4FFD3;
   background-color: #6DA203;
}
相關文章
相關標籤/搜索