html - 带有ul和左右图标的导航栏 : icons on the right get pushed down

标签 html css html-lists css-position navbar

我已经完成了整个导航栏,一切都很完美,但是右侧沙子上的按钮,在导航栏菜单之后,被推到下一行并弄乱了整个导航栏,使其变得非常厚。

我已经隔离了所有代码,我认为它看起来非常干净。

那是我的 index.html

<html>
<head>
    <meta charset="utf8" />
    <title>My about page</title>
    <link rel="stylesheet" href="css/style.css" />
</head>
<body>
    <header>
        <div class="wifi">
            <img src="img/wifi.gif" alt="Wi-Fi" />
        </div>
        <div class="opcoes">
            <ul>
                <li><a href="#">Início</a></li>
                <li><a href="#">Casa</a></li>
                <li><a href="#">Quartos</a></li>
                <li><a href="#">Contato</a></li>
            </ul>
        </div>

        <div class="flags">
            <ul>
                <li>
                    <img src="img/flag_en.gif" alt="English" />
                </li>
                <li>
                    <img src="img/flag_pt.gif" alt="Português" />
                </li>
            </ul>
        </div>
    </header>

</body>
</html>

这是我的 style.css

body {
    margin: 0;
}

header {
    overflow: hidden;
}

header{
    text-align: center;
    background: #C07D41;
}

.opcoes li{
    display: inline;
}

.opcoes li:after{
    content:'|';
    padding: 0 8px;
} 

.opcoes li:last-child:after{
    content: none;
}

.wifi{
    float: left;
    padding: 13px 8px;
}

.flags li{
    display:inline;
    float:right;
    padding: 0 8px;
}

任何帮助表示赞赏,真的坚持下去,需要左右图标和集中导航栏,我这样做是可能的还是我必须使用表格?真的不知道,已经研究了几个小时了。

谢谢

最佳答案

.opcoes 类的 css 中使用 float left,在 .flags 类上使用 float right

或者让它们display:inline-block;

关于html - 带有ul和左右图标的导航栏 : icons on the right get pushed down,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17768120/

相关文章:

css - Facebook 页面设计在 IE8 中不起作用

html - 使用 li 元素作为按钮

html - 保持 UL > LI 内容内联

html - 如何避免 th 元素从 IE6/7 中的 tr 元素继承属性

javascript - 如何将 GET 值附加到页面上每个链接的末尾

html - 表格列 - 首先使用最大宽度,其他宽度最小

javascript - 可以将伪类 (::after) 添加为 HTML 标记的一部分吗?

javascript - 可折叠菜单需要最终调整(jquery)

css - 调整列表样式图像位置?

javascript - 增加 DIV 数字变量的按钮