响应式导航栏 100% 宽度



我有一个导航栏,它由按钮/复选框组成,使其响应,我要么希望栏占据浏览器的整个宽度,它必须是响应式的(因此随着浏览器变小而缩小)或只是居中。.HTML:

    <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="Index_files/style.css">
<label for="show-menu" class="show-menu">Expand Menu</label>
<input type="checkbox" id="show-menu" role="button" width="100%">
<ul id="menu">
    <li><a href="index.html"><img src="Index_files/Images/Coldplay Logo Transparent.png" style="height:100%;"></a>          </li>
    <li>
        <a>Music ↓</a>
        <ul class="hidden">
            <li><a href="Index_files/Webpages/musicTracks.html">Music Tracks</a></li>
            <li><a href="Index_files/Webpages/musicVideos.html">Music Videos</a></li>
        </ul>
    </li>
    <li><a href="Index_files/Webpages/Tour.html">Tour</a></li>
    <li><a href="Index_files/Webpages/Gallery.html">Gallery</a></li>
    <li><a href="Index_files/Webpages/Feed.html">Feed</a></li>
    <li><a>Store ↓</a>
        <ul class="hidden">
            <li><a href="Index_files/Webpages/storeTickets.html">Tickets</a></li>
            <li><a href="Index_files/Webpages/storeMerch.html">Merchandise</a></li>
        </ul>
    </li>
    <li><a href="Index_files/Webpages/Contact.html">Contact</a></li>
</ul>

.CSS:

/*ul of padding and list styling*/
ul {
    list-style-type:none;
    margin:0;
    padding:0;
    position: absolute;
    display:table;
    margin: 0 auto;
}
/*Create horizontal list with spacing*/
li {
    display:inline-block;
    float:left;
    margin-right: 1px;
}
/*Style for menu links*/
li a {
    display:block;
    align-content:center;
    align-items:center;
    min-width:140px ;
    height: 50px;
    text-align: center;
    line-height: 50px;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: #fff;
    background: #303133;
    text-decoration: none;

}

在 css 中: #menu{ 宽度: 100%; }

相关内容

  • 没有找到相关文章

最新更新