Search code examples
cssunderline

CSS code for underline style for menu items


I would like to know the CSS code used to make the underline effect for the menu items of this website : https://www.kevin-missud-charpente.fr/

Thanks in advance.


Solution

  • this is better

    body,html {
      margin: 0;
      font: bold 14px/1.4 'Open Sans', arial, sans-serif;
      background: #fff;
    }
    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; 
    }
    @media screen and (max-height: 300px) {
        ul {
            margin-top: 40px;
        }
    }
    <ul>
      <li><a href="#">Home</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Contact</a></li>
      <li><a href="#">Support</a></li>
    </ul>

    this is on hover underline effect