gpt4 book ai didi

javascript - 如何在表行中实现类似 Spotify 播放按钮的按钮 css

转载 作者:搜寻专家 更新时间:2023-10-31 23:23:26 26 4
gpt4 key购买 nike

您好,我试过像 Spotify 一样自定义我的按钮。

悬停表格行时显示播放按钮并单击播放按钮更改图像。

enter image description here

我引用了其他 fiddle 并进行了更新。现在我单击一个元素,另一个将隐藏。但是,一开始我不知道如何隐藏其中一个。

a {
display: block;
font-size: 18px;
border: 2px solid gray;
border-radius: 100px;
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
}
a:hover {
font-size: 18px;
border: 2px solid green;
border-radius: 100px;
width: 100px;
height: 100px;
}
a:target {
display: none;
font-size: 18px;
border: 2px solid red;
border-radius: 100px;
width: 100px;
height: 100px;
}
<a id="btn" href="#btn">Play</a>
<a id="btn2" href="#btn2">Pause</a>

最佳答案

您可以在不编写脚本的情况下使用纯 css 执行以下操作。

a {
display: block;
font-size: 18px;
border: 2px solid gray;
border-radius: 100px;
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
}
a:hover {
font-size: 18px;
border: 2px solid green;
border-radius: 100px;
width: 100px;
height: 100px;
}
a:target {
display: none;
font-size: 18px;
border: 2px solid red;
border-radius: 100px;
width: 100px;
height: 100px;
}
a:nth-last-child(2){
display:none;
}
a:first-child:target + a:nth-last-child(2){
display:block;
}
<a id="btn" href="#btn">Play</a>
<a id="btn2" href="#btn2">Pause</a>

关于javascript - 如何在表行中实现类似 Spotify 播放按钮的按钮 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35740504/

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