无法将菜单项对齐到右侧

时间:2014-01-18 12:56:08

标签: html css

我正在尝试将菜单项对齐到右侧,但它不起作用。我想这是因为我使用了float:left以正确的顺序显示水平菜单。我无法解决这个问题所以我正在寻求帮助。

我可以在http://elexode.nl

找到我的问题的演示

这是我的css:

/* RESET */

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}

/* OWN CONTENT */

body { 
    background:url('bg.jpg') fixed no-repeat;
    font-family:Tahoma, Geneva, sans-serif;
}

#padding-inline {
    padding:10px 0;
}

.container {
    background:white;
}

.nav-menu {
    height:47px;
}

.nav-menu ul {
    line-height:47px;
    float:left;
    list-style-type:none;
}

.nav-menu li {
    display:inline;
}

.nav-menu ul li a {
    float:left;
    text-decoration:none;
    color:#5C5C5C;
    padding:0 5px;
}

.nav-menu ul li a:hover {
    color:#000000;
}

3 个答案:

答案 0 :(得分:0)

将浮动更改为右侧

nav-menu a {
    color: rgb(51, 51, 51);
    text-decoration: none;
    padding: 0px 5px;
    float: right;
}

并更改链接的顺序:

<ul>
    <li><a href='index.html'>VIDEOS</a></li>
    <li><a href='index.html'>MUSIC</a></li>
    <li><a href='index.html'>BIO</a></li>
    <li><a href='index.html'>HOME</a></li>
</ul>

并且您没有关闭锚标记...您应该关闭它。

由于您刚开始创建网站,我建议您尝试使用一些css框架,例如Foudation 5 http://foundation.zurb.com

它可以帮助您轻松创建响应式网站。它支持多种导航样式。查看文档http://foundation.zurb.com/docs/

答案 1 :(得分:0)

我检查了该链接,看起来您的HTML已损坏:为什么<a>之后<li>为什么?

<ul>
    <li><a href="index.html">
           HOME</a>
    </li>
      <a href="index.html"> </a>
    <li><a href="index.html"></a><a href="index.html">BIO</a></li><a href="index.html">
                    </a><li><a href="index.html"></a><a href="index.html">MUSIC</a></li><a href="index.html">
                    </a><li><a href="index.html"></a><a href="index.html">VIDEOS</a></li><a href="index.html">
                </a></ul>

答案 2 :(得分:0)

我猜你只想将HOME MUSIC BIO VIDEOS转移到右边?

我只是为ul添加了一个边距。

.nav-menu {
    height: 47px;
    margin-left: 80px;
}

但我不确定那是你要找的东西。

相关问题