开发者

CSS position issue

开发者 https://www.devze.com 2023-02-09 22:17 出处:网络
basically i have div with width of 960px and it has navigation on right hand, the navigation works fine, just the last sub navigation shows content extended to 960px, so i was wondering if somehow i c

basically i have div with width of 960px and it has navigation on right hand, the navigation works fine, just the last sub navigation shows content extended to 960px, so i was wondering if somehow i can push it to left side, without pushing top navigation with it, i been trying but it dont work. following is the example and css code

navigation, the last black line is the end开发者_如何学Go of 960px;

CSS position issue

screenshot for navigation question two (question from comment)

CSS position issue

css code example

#topNav {
    float: right;
    position: relative;
}
    #topNav li {
        position: relative;
        float: left;
        line-height:1.5em;
        padding: 0 .5em;
    }
    #topNav a span {
        clear: both;
    }
    #topNav ul ul {
        display:none;
        position: absolute;
        top: 20px;
        right: 0;
    }
    #topNav ul ul li {
        float:none;
        white-space:nowrap;
        position: relative;
        margin:0;
    }
    #topNav li.active {
        height: 50px;
        background-color:#FFF;
        border-top:#666 1px solid;
        border-right:#666 1px solid;
        border-left:#666 1px solid;
        border-bottom:#FFF 1px solid;
        z-index: 2;
    }
    #topNav ul ul.active {
        display: block;
        background-color:#F8F8F8;
        border:#666 1px solid;
        margin-top: -1px;
        margin-right: -1px;
        z-index: 1;
    }

html 5 code

<nav id="topNav">
            <ul>
              <li class="active"><a href="/">Home</a></li>
              <li><a href="#" title="Nav Link 3">Everyone</a></li>
              <li><a href="#" title="Profile">Profile</a></li>
              <li><a href="#" title="Account" >Account</a>
                    <ul>
                        <li><a href="#" title="Edit Freinds">Edit Friends</a></li>
                        <li><a href="#" title="Account Settings">Account Settings</a></li>
                        <li><a href="#" title="Privacy Settings">Privacy Settings</a></li>
                        <li><a href="#" title="Help Center">Help Center</a></li>
                        <li><a href="#" title="Logout">Logout</a></li>
                    </ul> 
              </li>
              <li><a href="#" title="Layouts" class="active">Layouts</a>
                    <ul class="active">
                        <li><a href="#" title="Default">Default Layout</a></li>
                        <li><a href="#">Default Elements</a></li>
                        <li><a href="#">Default Form</a></li>
                        <li><a href="#">Media Detail</a></li>
                    </ul>        
                </li>
            </ul>
        </nav>


Try adding the following:

#topNav ul ul {
    right: 0;
}

Rather than left: 0;. This should make it line up with the right hand side of the top menu item (Layouts in this case), rather than the left hand side.

0

精彩评论

暂无评论...
验证码 换一张
取 消