html - 向右浮动菜单栏的最后一项

标签 html css wordpress menu

我正在尝试 float 菜单栏中的最后一项 like here回到我的 wordpress,但我无法让它工作。有没有一种实用的方法来做到这一点?

li:nth-last-child(1) {
    float: none;
    display: inline-block;
}

最佳答案

就在我的脑海中,我会尝试绝对定位。

li:nth-last-child(1) {
position: absolute;    
top:0;
right:0;
display: inline-block;
}

你可能会发现 absolute 会打断文档的顺序,所以实际上,给你的左上角和左边一些填充,或者如果你像我一样懒惰......我做到了:

li:nth-last-child(1) {
position: absolute;    
top:0.5em;
right:0.5em;
display: inline-block;
}

关于html - 向右浮动菜单栏的最后一项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41855786/

相关文章:

php - woocommerce 在结帐和购物车页面中更改价格

javascript - 如何使用 jQuery 和 Galleria 更新 HTML 元素?

html - 为什么 ul 和第一个 li 元素之间有一个空格?

javascript - 如何让我的复选框值和选项值相加并将总和输入到我的文本区域?

javascript - 使用for循环在HTML div中显示JSON内容

css - 为 Wordpress OneAll 社交登录插件自定义 iframe

html - RGBA 不适用于 HTML 电子邮件

css - 如何为子站点制作配色方案

css - Windows 版 Safari 5.0.5 中 <selects> 的宽度

html - 侧边栏宽度恒定的 CSS 两列布局