- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想将链接和按钮水平居中,但坦率地说,我不知道该怎么做。非常感谢您的帮助!
我已经尝试过 text-align: center;
但它不起作用。
<nav>
<a href="#">Home</a>
<div>
<button>Products</button>
<div>
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
<a href="#">About</a>
</nav>
nav {
overflow: hidden;
background-color: #333;
}
nav a {
float: left;
color: white;
text-align: center;
padding: 15px;
text-decoration: none;
}
nav div {
float: left;
overflow: hidden;
}
nav div button {
line-height: inherit;
border: none;
outline: none;
color: white;
padding: 15px;
font-size: 1em;
background-color: inherit;
font-family: inherit;
margin: 0;
}
nav a:hover, nav div button:hover {
background-color: #222;
}
nav div div {
display: none;
position: absolute;
background-color: #eee;
min-width: 160px;
z-index: 1;
}
nav div div a {
float: none;
color: black;
padding: 12px;
text-decoration: none;
display: block;
text-align: left;
}
nav div div a:hover {
background-color: #ddd;
}
nav div:hover > div {
display: block;
}
最佳答案
请试试这段代码..
CSS
nav {
display: flex;
display: -webkit-flex; *for cross browser*
justify-content: center;
-webkit-justify-content: center; *for cross browser*
}
关于html - 导航栏中的中心链接和按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57737584/
我在让我的操作栏显示图标时遇到问题。它显示了我在溢出菜单中设置的文本/标题(三个点),但没有任何操作。这是我的代码,我错过了什么? MainActivity.java public class Mai
我正在尝试在 android 中制作一个动态操作栏,现在我正在尝试像这样在操作栏中进行搜索。 http://developer.android.com/images/ui/actionbar-sear
我正在编写 uiautomator 测试,但我很难弄清楚如何单击我的操作栏图标。 如果我的操作是“始终”显示,则很容易找到并点击。 如果我的操作是显示“从不”,我必须单击菜单,然后从菜单中单击。先点击
我有一个正在寻找特定 URI 的重写规则。当它匹配特定的 URL 时,它会使用正确的文件路径重写它,以便可以找到所需的内容。然后它将协议(protocol)更改为 HTTPS 并允许请求通过。 我有两
我正在为 android 中的 ActionBar 而苦苦挣扎。 这是我的问题:我的操作项没有显示在操作栏中,而是堆叠在操作溢出中,无论我做什么.. 我花了一天的时间寻找解决方案,但我似乎找不到缺少的
我的网络应用程序在 Tomcat 下运行,它非常密集地使用 AJAX 请求,在开发过程中我也必须密集地重新部署网络应用程序。重新部署后,我通常会简单地刷新页面,知道用户 session 已删除,但我总
我是一名优秀的程序员,十分优秀!