1

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 .

2 Answers2

0

This should fix it for you

.menu-bar a {
    border:2px solid transparent;    
}
Manav
  • 1,357
  • 10
  • 17
  • Thanks for anwer . it fixs but it creats unvisible border first , then when hover the mouse border this appear and looks it doesnt move . But what i want to do is , when to first border apper , should stay on the position – Furkan Akgün Oct 27 '20 at 14:34
  • @FurkanAkgün Because the width of the tag increases, due to the border, the other elements are shifted – Manav Oct 27 '20 at 14:35
  • An alternate would be to reduce the width of the element by the size of the border, but this would be a better option – Manav Oct 27 '20 at 14:36
0

Instead of the border use this -

.menu-bar a:hover {
  box-shadow: inset 0 0 0 2px red;
}
Tanim
  • 1,256
  • 8
  • 14