Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elements move on hover because border is added, padding, as suggested elsewhere doesn't seem to work

When I hover over an area on my testing website, I made it so a border is added. But because that happens, other elements move. I've looked up other posts, and they recommended adding padding, but that doesn't seem to work because it goes over other stuff.

This is where I add the border:

#logo:hover {
  border: 2px solid cyan;
}

This is what it was added to:

#logo {
    width: 200px;
    height: 200px;
    position: relative;
    top: 80px;
    line-height: 12em;
    border-radius: 200px;
    margin: 0 10px 0 10px;
    overflow: hidden;
}

Does anyone know how to help me? Also about the way I asked my question.

#logo {
    background-color: black;
    width: 200px;
    height: 200px;
    position: relative;
    top: 80px;
    line-height: 12em;
    border-radius: 200px;
    margin: 0 10px 0 10px;
    overflow: hidden;
}

#logo:hover {
  border: 2px solid cyan;
}
<div id=logo></div>

Greetings, TheWombatGuru

like image 760
The Coding Wombat Avatar asked Oct 24 '25 05:10

The Coding Wombat


2 Answers

You also can use box shadow:

 #logo{
    box-shadow: inset 0 0 0 1px cyan;
 }

 #logo:hover {
    box-shadow: inset 0 0 0 2px cyan;
 }
like image 168
Ursu Alexandr Avatar answered Oct 26 '25 19:10

Ursu Alexandr


You may add:

* {  box-sizing: border-box;}

to your css sheet or maybe just to your #logo id.

you may find more info about this (for me at least amazing propertie ) here

(and just in case... the code marked applied the property to every html element in your web, which is exactly what I have been doing in my last many projects with absolutely no regret)

like image 36
Alvaro Menéndez Avatar answered Oct 26 '25 19:10

Alvaro Menéndez