Search code examples
htmlcssborder

How do keep position when borders appear?


I am trying to keep on the position when it creates borders of the list elemants on the menu. When i do border box is looks "it is not working" (ı am sure it is , but i cant see it )

Here is the my basic Html Code

<div class="menu-bar">
        <ul>
            <li><a href="anasayfa.html" class="alt-cizgi">Anasayfa</a></li>
            <li><a href="hakkimizda/hakkimizda.html">Hakkımızda</a></li>
            <li><a href="kadromuz/kadromuz.html">Kadromuz</a></li>
            <li><a href="calismaalanlarimiz/calismaalanlarimiz.html">Çalışma Alanlarımız</a></li>
            <li><a href="vekaletbilgileri/vekaletbilgileri.html">Vekalet bilgileri</a></li>
            <li><a href="">İletişim</a></li>
        </ul>
    </div>

Here is my Css Code

 .menu-bar{    
    width: 1000px;
    height: 50px;
    background-color:#212331;
    box-sizing: border-box;
}
.menu-bar ul {
    margin-top: 0px;
    list-style-type: none;
}
.menu-bar li {
    display: inline-block;
    margin-left: 30px;
}
.menu-bar a {
    font-family:'Open Sans', sans-serif;
    font-weight: bold;
    color:#ffffff;
    text-decoration: none;
    line-height: 50px;
    padding: 15px 10px;
    
}
.menu-bar a:hover{
    border:2px solid red;
    color: #cf9452;
    transition: 0.5s;
}

Here is the what is actually going on the page .


Solution

  • Instead of the border use this -

    .menu-bar a:hover {
      box-shadow: inset 0 0 0 2px red;
    }