English 中文(简体)
Have center
原标题:Have menu buttons centered css dropdown menu

我正在利用这些奇子打碎我的菜单。 现行准则为<代码>float:左侧,显然将其置于左边,然而,我真的喜欢放在中间。

www.un.org/spanish/ecosoc 是否有任何人帮助我修改这一请求?

.menu{

border:none;
border:0px;
margin:0px;
padding:0px;
font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
}
.menu ul{

background:#6991B7;
height:35px;
list-style:none;
margin:0;
padding:0;

}
.menu li{

    float:left;
    padding:0px;

    }
.menu li a{
    background:#6991B7 url("images/seperator.gif") bottom right no-repeat;
    color:#FFF;
    display:block;
    font-weight:normal;
    line-height:35px;
    margin:0px;
    padding:0px 25px;
    text-align:center;
    text-decoration:none;
    }
    .menu li a:hover, .menu ul li:hover a{
        background: #2580a2 url("images/hover.gif") bottom center no-repeat;
        color:#FFFFFF;
        text-decoration:none;
        }
.menu li ul{
    background:#333333;
    display:none;
    height:auto;
    padding:0px;
    margin:0px;
    border:0px;
    position:absolute;
    width:225px;
    z-index:200;
    /*top:1em;
    /*left:0;*/
    }
.menu li:hover ul{
    display:block;

    }
.menu li li {
    background:url( images/sub_sep.gif ) bottom left no-repeat;
    display:block;
    float:none;
    margin:0px;
    padding:0px;
    width:225px;
    }
.menu li:hover li a{
    background:none;

    }
.menu li ul a{
    display:block;
    height:35px;
    font-size:12px;
    font-style:normal;
    margin:0px;
    padding:0px 10px 0px 15px;
    text-align:left;
    }
    .menu li ul a:hover, .menu li ul li:hover a{
        background:#2580a2 url( images/hover_sub.gif ) center left no-repeat;
        border:0px;
        color:#ffffff;
        text-decoration:none;
        }
.menu p{
    clear:left;
    }   
最佳回答

我认为,你想看到,你的航海是检查这一法典的中心,在你的法典中有一些改动。

1. text-align:center put to .menu css
2. .menu li, .menu li a define to display:inline-block;
3. .menu ul define margin: 0 auto; and overflow:hidden; 

<>Cs

    .menu{

border:none;
border:0px;
margin:0px auto;
padding:0px;
font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
    text-align:center;
}
.menu ul{

background:#6991B7;
height:35px;
list-style:none;
margin:0 auto;
padding:0;
    overflow:hidden;

}
.menu li{

    display:inline-block;
    padding:0px;

    }
.menu li a{
    background:#6991B7 url("images/seperator.gif") bottom right no-repeat;
    color:#FFF;
    display:inline-block;
    font-weight:normal;
    line-height:35px;
    margin:0px;
    padding:0px 25px;
    text-decoration:none;
    }
    .menu li a:hover, .menu ul li:hover a{
        background: #2580a2 url("images/hover.gif") bottom center no-repeat;
        color:#FFFFFF;
        text-decoration:none;
        }
.menu li ul{
    background:#333333;
    display:none;
    height:auto;
    padding:0px;
    margin:0px;
    border:0px;
    position:absolute;
    width:225px;
    z-index:200;
    /*top:1em;
    /*left:0;*/
    }
.menu li:hover ul{
    display:block;

    }
.menu li li {
    background:url( images/sub_sep.gif ) bottom left no-repeat;
    display:block;
    float:none;
    margin:0px;
    padding:0px;
    width:225px;
    }
.menu li:hover li a{
    background:none;

    }
.menu li ul a{
    display:block;
    height:35px;
    font-size:12px;
    font-style:normal;
    margin:0px;
    padding:0px 10px 0px 15px;
    text-align:left;
    }
    .menu li ul a:hover, .menu li ul li:hover a{
        background:#2580a2 url( images/hover_sub.gif ) center left no-repeat;
        border:0px;
        color:#ffffff;
        text-decoration:none;
        }
.menu p{
    clear:left;
    }   

<><><><>>><>>>>><>>>>>>>

<div class="menu">
<ul>
    <li><a href="#">Demo link</a></li>
    <li><a href="#">Demo link</a></li>
    <li><a href="#">Demo link</a></li>
    <li><a href="#">Demo link</a></li>
    <li><a href="#">Demo link</a></li>
    <li><a href="#">Demo link</a></li>
</ul>
</div>

Live demo http://jsfiddle.net/rohitazad/g3hLK/1/

问题回答

www.un.org/Depts/DGACM/index_french.htm

您可以宣布您的菜单(lis>为:inline-block,然后通过使用text-align:center等财产自动将其单箱放在:

.menu{
    border:none;
    border:0px;
    margin:0px;
    padding:0px;
    font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
    font-size:14px;
    font-weight:bold;
    text-align:center;
}

.menu li{
    display:inline-block;
    *display:inline; /* ie7 fix */
    padding:0px;
}




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签