如何将此导航栏扩展到页面外?

时间:2012-08-01 17:06:59

标签: html css

我有一个css导航栏,我想延伸到我的网页的两侧。现在它有一个非常小的宽度,似乎无论我玩多少比例没有什么变化。任何人都可以帮我吗?我对网页设计很陌生。我将发布我的CSS和HTML

CSS:

/* Links */

.menu li a {
    display: block;
    padding: 0 14px;
    margin: 6px 0;
    line-height: 28px;
    text-decoration: none;

    border-left: 1px solid #4075a6;
    border-right: 1px solid #4075a6;

    font-family: Archer,Helvetica, Arial, sans-serif;
    font-weight: light;
    font-size: 13px;

    color: white;
    text-shadow: 0px 0px 0px rgba(0,0,0,.6);

    -webkit-transition: color .2s ease-in-out;
    -moz-transition: color .2s ease-in-out;
    -o-transition: color .2s ease-in-out;
    -ms-transition: color .2s ease-in-out;
    transition: color .2s ease-in-out;
}

.menu li:first-child a { border-left: none; }
.menu li:last-child a{ border-right: none; }

.menu li:hover > a { color: #b8ccdc; }

/* Sub Menu */

.menu ul {
    position: absolute;
    top: 40px;
    left: 0;
    opacity: 0;
    background: #195892;
    -webkit-border-radius: 0 0 5px 5px;
    -moz-border-radius: 0 0 5px 5px;
    border-radius: 0 0 5px 5px;

    -webkit-transition: opacity .25s ease .1s;
    -moz-transition: opacity .25s ease .1s;
    -o-transition: opacity .25s ease .1s;
    -ms-transition: opacity .25s ease .1s;
    transition: opacity .25s ease .1s;
    width: 101px;
}

.menu li:hover > ul { opacity: 1; }

.menu ul li {
    height: 0;
    overflow: hidden;
    padding: 0;

    -webkit-transition: height .25s ease .1s;
    -moz-transition: height .25s ease .1s;
    -o-transition: height .25s ease .1s;
    -ms-transition: height .25s ease .1s;
    transition: height .25s ease .1s;
}

.menu li:hover > ul li {
    height: 36px;
    overflow: visible;
    padding: 0;
}

.menu ul li a {
    width: 100px;
    padding: 0px 0px 0px 0px;
    margin: 0;

    border: none;
    border-bottom: 1px solid #353539;
}

.menu ul li:last-child a {
    border: none;
    color: #195892;
}

HTML:

<ul class="menu">
    <li><a href="#">Home</a></li>
    <li><a href="#">Developements</a></li>
    <li><a href="#">Condominiums</a>
    <ul>
        <li><a href="#" class="documents">Documents</a></li>
        <li><a href="#" class="messages">Messages</a></li>
        <li><a href="#" class="signout">Sign Out</a></li>
    </ul>
    </li>
    <li><a href="#">Video Tours</a></li>
    <li><a href="#">Contact </a></li>
</ul>
<!-- end .menu -->

2 个答案:

答案 0 :(得分:0)

您需要在UL上将宽度设置为所需的宽度。我认为100%会对你有用,因为它会从它所包裹的容器的边缘到边缘。

我建议在UL和LI上放置背景颜色,以便您可以轻松查看它们的开始和结束位置,然后在将它们放置到您想要的位置后将其移除。

答案 1 :(得分:0)

我需要将我的.menu更改为100%宽度并添加位置:绝对;右:0;左:0;这很有效。