在悬停时使用display:block with bottom-border

时间:2015-02-04 12:00:43

标签: html css

我想像这样悬停:http://i.imgur.com/yi3Ehu2.png

我做过类似的事情:http://jsfiddle.net/szsq2424/

如果我在锚元素上使用botom-border而不使用display: block来悬停,则看起来就像我想要的那样。但是当我在白色标题类中的display: block元素上使用a时(为了使所有按钮都可以点击,而不仅仅是文本),它会将该边框缩小到按钮的底部。有些想法啦?谢谢 !我是html + css的新手,感谢您的帮助!

2 个答案:

答案 0 :(得分:1)

用锚点将文本包裹在锚点内,并将边框应用于该文本。



.white-header {
  width: 1400px;
  background-color: white;
  margin: 0;
  padding: 0;
}

.white-header ul {
  margin: 0 0 0 100px;
  padding: 0;
}

.white-header ul li {
  list-style: none;
  float: left;
  line-height: 60px;
}

.white-header ul li a {
  display: block;
  text-align: center;
}

.white-header ul li a:link,
.white-header ul li a:visited {
  color: #3f3f3f;
  text-decoration: none;
}

.white-header ul li a:hover {
  color: #57C5A0;
}

.white-header ul li a:hover span {
  color: #57C5A0;
  border-bottom: 2px solid #57C5A0;
}

/********
FIRST BUTTON
********/

.white-first {
  width: 120px;
  max-height: 60px;
  text-align: center;
  border-left: 1px solid #383838;
  border-right: 1px solid #383838;
}

/********
SECOND BUTTON
*********/

.white-second {
  width: 150px;
  text-align: center;
  border-right: 1px solid #383838;
  margin: 0;
}

.white-second a:link,
.white-second a:visited {
  color: black;
  text-decoration: none;
}

.white-second a:hover {
  color: #57C5A0;
  padding-bottom: -10px;
}

/******
VISA LIETUVA BUTTON
*******/

.white-third {
  width: 270px;
  border-right: 1px solid #383838;
}

  <header class="white-header">
        <ul>
            <li class="white-first"><a href="#"><span>Pramogos</span></a></li>
          <li class="white-second"><a href="#"><span>Pramogos</span></a></li>
          <li class="white-third"><a href="#"><span>Pramogos</span></a></li>
        </ul>
 </header>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

您可以将text-decoration: underline添加到:hover以获得结果,例如提供的图片

相关问题