html - 单独的内联列表

标签 html css list

我一直在尝试分离一个已经内联的列表,下面是 HTML 代码。

<div class="TopNavigation">
    <ul class="Separate">
        <li><a href="index.html">Home</a></li>
        <li><a href="#">Gallery</a></li>
        <li><a href="index3.html">Tools</a></li>
    </ul>
</div>

这是 CSS 代码。

.TopNavigation a {
    color: Black;
    font-size: 15px;
    font-weight: bold;
    padding: 14px 10px;
    text-transform: uppercase;
    font-family: 'Century Gothic', CenturyGothic, AppleGothic, sans-serif;
    font-size: 14px;
    font-style: normal;
    font-variant: normal;
    font-weight: 400;
    line-height: 20px;
}

.TopNavigation li {
    display: inline-block;
}

.TopNavigation {
    padding-top: 10px;
}

我希望“主页”位于页面左侧,“图库”和“工具”位于页面右侧。我该怎么做?

谢谢。

最佳答案

您可以将 float:right 分配给除列表的第一个 li 元素之外的所有元素:

.TopNavigation a {
    color: Black;
    font-size: 15px;
    font-weight: bold;
    padding: 14px 10px;
    text-transform: uppercase;
    font-family: 'Century Gothic', CenturyGothic, AppleGothic, sans-serif;
    font-size: 14px;
    font-style: normal;
    font-variant: normal;
    font-weight: 400;
    line-height: 20px;
}

.TopNavigation li {
    display: inline-block;
}

.TopNavigation {
    padding-top: 10px;
}
.TopNavigation li:not(:first-of-type) {
  float:right;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="TopNavigation">
    <ul class="Separate">
        <li><a href="index.html">Home</a></li>
<li><a href="index3.html">Tools</a></li>            
<li><a href="#">Gallery</a></li>
        
    </ul>
</div>

关于html - 单独的内联列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27635982/

相关文章:

html - 调整窗口大小时,所有内容都被压缩而不是显示滚动条

html - 服务器存储的字体与谷歌字体?

html - 头部容器的高度是动态的

html - 如何水平对齐未排序的列表?

html - 垂直列表(从水平返回到默认值)

jquery - Bootstrap Collapse 第一次没有动画,第一次后有抖动动画

javascript - 使用多个 html 页面或通过 javascript 显示/隐藏 div

list - Scheme中列表(或其他内容)的副本

javascript - HTML 如何返回页面并滚动到页面中的特定点

html - CSS Drop down 在悬停时不会变得可见,但会在悬停时隐藏