导航菜单项下划线效果

Gio*_*dze 3 css wordpress

我试图让导航菜单项在悬停时具有下划线效果。这是我当前style.css的导航菜单代码。

我应该添加什么才能使它看起来像这样?示例:http : //www.templatemonster.com/demo/54038.html

这是我当前的导航条码。

.navbar-nav .open .dropdown-menu{
display:block !important;
}
.navbar-default .navbar-nav > li > a {
  color: #333;
  border-bottom: 1px solid transparent;
  padding: 0; 
  margin: 14px; 
Run Code Online (Sandbox Code Playgroud)

小智 6

尝试这个..

HTML:

<ul>
  <li><a href="#">About</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)

CSS:

body,html {
  margin: 0;
}
ul { 
  margin: 150px auto 0; 
  padding: 0; 
  list-style: none; 
  display: table;
  width: 600px;
  text-align: center;
}
li { 
  display: table-cell; 
  position: relative; 
  padding: 15px 0;
}
a {
  color: #000;
  text-transform: uppercase;
  text-decoration: none;
  letter-spacing: 0.15em;

  display: inline-block;
  padding: 15px 20px;
  position: relative;
}
a:after {    
  background: none repeat scroll 0 0 transparent;
  bottom: 0;
  content: "";
  display: block;
  height: 2px;
  left: 50%;
  position: absolute;
  background: #000;
  transition: width 0.3s ease 0s, left 0.3s ease 0s;
  width: 0;
}
a:hover:after { 
  width: 100%; 
  left: 0; 
}
Run Code Online (Sandbox Code Playgroud)

https://jsfiddle.net/y4hc9Lbv/