gpt4 book ai didi

html - 如何在悬停时隐藏菜单中的文本并用下划线代替图像?

转载 作者:太空宇宙 更新时间:2023-11-04 11:49:37 25 4
gpt4 key购买 nike

我想在顶部制作菜单,并在悬停鼠标时隐藏文本和显示图标。并在图标下添加下划线。在我的代码中,我成功地将文本更改为图像,但是如何在图像下添加下划线并使下划线宽度为 3px,长度为 60px?这是我的代码- HTML:

<div class="menu topMenu">
<ul class="topMenuOptions">
<li><span>111</span></li>
<li><span>222</span></li>
<li><span>333</span></li>
</ul>

CSS:

.topMenu {
text-transform: uppercase;
background-image: url('images/1.png');
position: absolute;
height: 88px;
width: 400px;
background: lightcoral;
margin-left: 332px;
padding-top: 30px;
}

.topMenuOptions {
padding: 0;
margin: 0;
margin-left: 155px;
list-style-type: none;
}

.topMenuOptions li {
cursor: pointer;
padding: 10px;
color: white;
font-size: 14px;
display: inline;
}

.topMenuOptions li:hover:nth-child(1) {
background: url('images/2.png') center center no-repeat;
background-position: 20px 0;
background-size: contain;
color:transparent;
}

.topMenuOptions li:hover:nth-child(2) {
background: url('images/3.png') center center no-repeat;
background-size: contain;
background-position: 20px 0;
color: transparent;
}

.topMenuOptions li:hover:nth-child(3) {
background: url('images/4.png') center center no-repeat;
background-size: contain;
background-position: 20px 0;
color: transparent;
}

最佳答案

使用border-bottom: 3px solid white;,例如:

.topMenuOptions li:hover:nth-child(1) {
background: url('images/2.png') center center no-repeat;
background-position: 20px 0;
background-size: contain;
color:transparent;
border-bottom: 3px solid #fff;
}

关于html - 如何在悬停时隐藏菜单中的文本并用下划线代替图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30740133/

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