我有一个灰色边缘的社交栏,当用户将鼠标移过它时,我一直试图让它(边缘)变红。
谁能帮我这个?甚至!重要的不起作用。
PS:我正在使用……
#subbtn{ background-color:transparent; border-width:0; cursor:pointer; color:grey; text-decoration: none; } #subbtn:hover{ cursor: pointer; color:red; }
在js中使用id = subbtn你要悬停并在css中编写这段代码,或者如果你想用jsp写它把它放在样式下,改变你想要的颜色名称,我百分百肯定它会正常工作
改变了 a:hover 成 a>li>i:hover 会改变 :hover 你的社交酒吧。原因是HTML代码的结构是 a 标签然后 li 然后 i 。
a:hover
a>li>i:hover
:hover
a
li
i
如果你有一个特定的分类类,我会说 a>li>i 你的社交酒吧和其他 a>li>i 如果你有一个,你可以添加类来区分它们。例: a>li>i.social 。不要忘记,如果你这样做添加 social 上课 i
a>li>i
a>li>i.social
social
footer { background-color: black; } .foot { font-family: 'Josefin Sans', sans-serif; font-style: normal; font-weight: 300; font-size: 21px; line-height: 36px; color: #e0e1d7; } a:link { color: white; } a>li>i:hover { color: red; text-decoration: none; } .container-fluid { padding-right: 0; padding-left: 0; } img { display: block; margin-left: auto; margin-right: auto; max-width: 100%; } .copyright { font-family: Arial; font-style: normal; font-weight: 400; font-size: 15px; line-height: 18px; color: #4b4b4b; } .list-inline-item { color: white; } .fab { background-color: grey; padding: 4px 5px; }
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous"> <footer> <div class="container-fluid text-center text-white"> <div class="row"> <div class="col-sm-12"> <img src="../../assets/footer.png" alt="black tint"> <div class="foot pt-5 pb-2"> <ul> <a href="http://www.pinterest.com"><li class="list-inline-item mx-2"><i class="fab fa-pinterest-p"></i></li></a> <a href="http://www.facebook.com"><li class="list-inline-item mx-2"><i class="fab fa-facebook-f"></i></li></a> <a href="http://www.linkedin.com"><li class="list-inline-item mx-2"><i class="fab fa-linkedin-in"></i></li></a> <a href="http://www.blog.com"><li class="list-inline-item mx-2"><i class="fab fa-blogger-b"></i></li></a> <a href="http://www.twitter.com"><li class="list-inline-item mx-2"><i class="fab fa-twitter"></i></li></a> <a href="http://www.youtube.com"><li class="list-inline-item mx-2"><i class="fab fa-youtube"></i></li></a> </ul> <p class="copyright">Copyright ? 2013 WEUSTHEM INC. ALL RIGHTS RESERVED.</p> </div> </div> </div> </div> </footer>
添加
a:hover li i { background-color: red; text-decoration: none; }
原位的
a:hover{ background-color: red; text-decoration: none; }
希望这可以帮助。谢谢
footer { background-color: black; } .foot { font-family: 'Josefin Sans', sans-serif; font-style: normal; font-weight: 300; font-size: 21px; line-height: 36px; color: #e0e1d7; } a:link { color: white; } a:hover li i { background-color: red; text-decoration: none; } .container-fluid { padding-right: 0; padding-left: 0; } img { display: block; margin-left: auto; margin-right: auto; max-width: 100%; } .copyright { font-family: Arial; font-style: normal; font-weight: 400; font-size: 15px; line-height: 18px; color: #4b4b4b; } .list-inline-item { color: white; } .fab { background-color: grey; padding: 4px 5px; }
<footer> <div class="container-fluid text-center text-white"> <div class="row"> <div class="col-sm-12"> <img src="../../assets/footer.png" alt="black tint"> <div class="foot pt-5 pb-2"> <ul> <a href="http://www.pinterest.com"><li class="list-inline-item mx-2"><i class="fab fa-pinterest-p"></i></li></a> <a href="http://www.facebook.com"><li class="list-inline-item mx-2"><i class="fab fa-facebook-f"></i></li></a> <a href="http://www.linkedin.com"><li class="list-inline-item mx-2"><i class="fab fa-linkedin-in"></i></li></a> <a href="http://www.blog.com"><li class="list-inline-item mx-2"><i class="fab fa-blogger-b"></i></li></a> <a href="http://www.twitter.com"><li class="list-inline-item mx-2"><i class="fab fa-twitter"></i></li></a> <a href="http://www.youtube.com"><li class="list-inline-item mx-2"><i class="fab fa-youtube"></i></li></a> </ul> <p class="copyright">Copyright ? 2013 WEUSTHEM INC. ALL RIGHTS RESERVED.</p> </div> </div> </div> </div> </footer>
强调文字
你必须使用里面的超链接 li 并添加父类 (footer li a:hover) 覆盖bootstrap默认的css。我希望这个答案会有所帮助。
(footer li a:hover)
footer { background-color: black; } .foot { font-family: 'Josefin Sans', sans-serif; font-style: normal; font-weight: 300; font-size: 21px; line-height: 36px; color: #e0e1d7; } footer li a:link { color: white; } footer li a:hover { color: red; text-decoration: none; } .container-fluid { padding-right: 0; padding-left: 0; } img { display: block; margin-left: auto; margin-right: auto; max-width: 100%; } .copyright { font-family: Arial; font-style: normal; font-weight: 400; font-size: 15px; line-height: 18px; color: #4b4b4b; } .list-inline-item { color: white; } .fab { background-color: grey; padding: 4px 5px; }
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> <footer> <div class="container-fluid text-center text-white"> <div class="row"> <div class="col-sm-12"> <img src="../../assets/footer.png" alt="black tint"> <div class="foot pt-5 pb-2"> <ul> <li class="list-inline-item mx-2"><a href="http://www.pinterest.com"><i class="fab fa-pinterest-p"></i></a></li> <li class="list-inline-item mx-2"><a href="http://www.facebook.com"><i class="fab fa-facebook-f"></i></a></li> <li class="list-inline-item mx-2"><a href="http://www.linkedin.com"><i class="fab fa-linkedin-in"></i></a></li> <li class="list-inline-item mx-2"><a href="http://www.blog.com"><i class="fab fa-blogger-b"></i></a></li> <li class="list-inline-item mx-2"><a href="http://www.twitter.com"><i class="fab fa-twitter"></i></a></li> <li class="list-inline-item mx-2"><a href="http://www.youtube.com"><i class="fab fa-youtube"></i></a></li> </ul> <p class="copyright">Copyright ? 2013 WEUSTHEM INC. ALL RIGHTS RESERVED.</p> </div> </div> </div> </div> </footer>
你可以通过添加父元素类来实现这一点,
.list-inline-item .fab:hover { background: red; }
由于“fab”类背景已设置为灰色,并且您不会对a:hover颜色或背景进行任何更改,因为“.fab”类位于“a”标记内