作者:jiajian123 | 来源:互联网 | 2023-05-17 21:37
IamtryingtobuildanavigationbarliketheGithubsone(withoutusingtheBootstrapnav*select
I am trying to build a navigation bar like the Github's one (without using the Bootstrap nav*
selectors - please see this jsfiddle
我正在尝试构建一个像Github一样的导航栏(不使用Bootstrap导航*选择器 - 请看这个jsfiddle
So I have the following HTML:
所以我有以下HTML:
Note the span9
class that I am using to force the navigation bar to occupy only 9/12 of my screen.
请注意我用来强制导航栏只占据屏幕9/12的span9类。
And the following CSS:
以下CSS:
.main-tabs {
position: relative;
margin-bottom: 20px;
font-size: 12px;
font-weight: bold;
background-color: #eaeaea;
background-image: -moz-linear-gradient(#fafafa, #eaeaea);
background-image: -webkit-linear-gradient(#fafafa, #eaeaea);
background-image: linear-gradient(#fafafa, #eaeaea);
background-repeat: repeat-x;
border: 1px solid #eaeaea;
border-bottom-color: #cacaca;
border-radius: 3px;
}
.main-tabs a {
display: block;
text-align: center;
line-height: 35px;
font-size: 12px;
color: #777;
text-decoration: none;
text-shadow: 0 1px 0 white;
border-right: 1px solid #eee;
border-right-color: rgba(0,0,0,0.04);
border-left: 1px solid #fcfcfc;
border-left-color: rgba(255,255,255,0.7);
border-bottom: 2px solid #DADADA;
}
.main-tabs li {
list-style-type: none;
}
.main-tabs li .active {
border-bottom: 2px solid greenyellow;
}
The result is:
结果是:
I changed .main-tabs li
to:
我把.main-tabs li更改为:
.main-tabs li {
list-style-type: none;
float: left;
}
Then
.main-tabs li {
list-style-type: none;
display: block;
}
This still gives the same results :(
这仍然给出相同的结果:(
But this did not really help.
但这并没有真正帮助。
QUESTION Without hardcoding the width of li
or ul
elements (for responsiveness matters), is there a way to get the same navigation bar like the one on Github?
问题没有硬编码li或ul元素的宽度(为了响应性问题),有没有办法获得与Github上相同的导航栏?
2 个解决方案