gpt4 book ai didi

html - 单击时导航中的元素会稍微分开

转载 作者:行者123 更新时间:2023-11-28 15:19:46 24 4
gpt4 key购买 nike

我有一个包含 4 个元素的导航元素。当我单击任何元素时,我注意到这些元素稍微分开,并且 div 展开。

<div id="siteNavigation" class="navDiv">
<nav>
<ul>
<li><span><a href="index.html" class="selected">Home</a></span></li>
<li><a href="resources\waiting_room.jpg">Meet Me</a></li>
<li><a href="resources\waiting_room.jpg">About</a></li>
<li><a href="resources\waiting_room.jpg">Contact</a></li>
</ul>
</nav>
</div>


.navDiv {
display: inline;
width: auto;
float: right;
border: solid;
}

nav ul {
clear: both;
list-style-position: inside;
clear: left;
list-style: none;
margin-left: 0;
width: auto;
padding-top: 32px;
text-align: center;
white-space: nowrap;
}

nav ul li {
display: inline-block;
white-space: nowrap;
padding-left: 8px;
border: none;
}

nav ul li a {
color: #000000;
/* #E3CF9C */
font-size: 1em;
font-weight: bold;
text-decoration: none;
letter-spacing: 0.05em;
padding: 10px 3.125% 26px 3.125%;
text-transform: uppercase;
border: none;
}

nav ul li a:hover {
color: #BF0000;
}

nav ul li a.selected {
color: #BF0000;
}

nav ul li a.selected:hover {
color: #E3CF9C;
}

JSFiddle 示例:https://jsfiddle.net/rfhasw48/1/

我需要更改什么才能使导航保持恒定大小?

最佳答案

只需从 nav ul li a 中删除填充。

更新的 CSS:

    .navDiv {
display: inline;
width: auto;
float: right;
border: solid;
}

nav ul {
clear: both;
list-style-position: inside;
clear: left;
list-style: none;
margin-left: 0;
width: auto;
padding-top: 32px;
text-align: center;
white-space: nowrap;
}

nav ul li {
display: inline-block;
white-space: nowrap;
padding-left: 8px;
border: none;
}

nav ul li a {
color: #000000;
/* #E3CF9C */
font-size: 1em;
font-weight: bold;
text-decoration: none;
letter-spacing: 0.05em;
text-transform: uppercase;
border: none;
}

nav ul li a:hover {
color: #BF0000;
}

nav ul li a.selected {
color: #BF0000;
}

nav ul li a.selected:hover {
color: #E3CF9C;
}

关于html - 单击时导航中的元素会稍微分开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46413152/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com