javascript - html,css中的所有链接都有相同的悬停
问题描述
ul li a:hover{
color: black;
}
/* Search Button */
.search_button{
float: right;
position: relative;
bottom: 78px;
margin-right: 10px;
height: auto;
}
/* Middle Section */
/* Middle Section Main Picture */
.middle_section_image{
display: block;
margin: 1px auto;
position: relative;
bottom: 50px;
}
/* quote, explore */
.quote{
text-align: center;
position: relative;
color: whitesmoke;
bottom: 475px;
font-size: 25px;
}
.explore{
width: 80px;
margin: auto;
padding: 0px 30px;
background-color: black;
color: whitesmoke;
text-align: center;
border: 1px solid black;
position: relative;
border-radius: 30px;
bottom: 475px;
}
这是我的 CSS 文件的一部分。我的文件中有很多链接,我想为它们添加不同的属性。但是,如果我将一个属性添加到一个链接,则相同的属性会添加到所有链接。我希望所有链接都有单独的属性
解决方案
There are different ways you could go about this.
You could add a css class or id selector for each of the different link types that you want to have:
/* class */
a.home-link { color: #000; }
a.home-link:hover { color: #00f; }
a.contact-link { color: #aaa; }
a.contact-link:hover { color: #0f0; }
/* id */
a#home-link { color: #000; }
a#contact-link { color: #aaa; }
...
You could also create css selectors based on known attributes that will be shared by links you want to target.
a[href="home.html"] { color: #000; }
a[href="contact.html"] { color: #000; }
推荐阅读
- optaplanner - Optaplanner:在自定义阶段访问起诉地图
- android - Android选项卡布局:无论标题内容如何,始终将选项卡指示器宽度包装为4dp
- python - 刮取同级Selenium
- stata - 更改非默认颜色的透明度
- python - OLS回归中的计数
- c++ - 树莓派 3 和 SG90 mini 伺服未知问题
- python - 为大块日期拆分数据框
- modal-dialog - 尝试从父对象中提取数据时,CascadingParameter 为空
- c++ - UVA 10249 或使用贪心算法的盛大晚宴
- javascript - 在 chrome 存储中存储多个对象