CSS objects in div move when hovering

lucanello

I am currently helping out a friend by adding social media icons to his website. I wanted to use a cool hovering effect, but when I hover the icons, they'll move inside the div. It's not very surprising, but I couldn't find any other way than adjusting the padding so it looks like they don't move. It doesn't look really decent and is kind of cheaty.

<script src="https://use.fontawesome.com/a63c918c5b.js" type="text/javascript">
</script>

<style media="screen" type="text/css">
  .icons {
    position: relative;
    padding: 9px;
  }
  .icons:hover {
    color: #4f5255;
    font-size: 19px;
    transition: font-size 0.2s;
    /*padding: 7px;*/
  }
  div {
    height: 100px;
    width: 200px;
    float: left;
  }
</style>

<div>
  <a target="_blank" href="link" class="icons fa fa-facebook" style="color: #4f5255;text-decoration:none;"></a>
  <a target="_blank" href="link" class="icons fa fa-twitter" style="color: #4f5255;text-decoration:none"></a>
  <a target="_blank" href="link" class="icons fa fa-instagram" style="color: #4f5255;text-decoration:none"></a>
</div>

I don't want the icons to move horizontally and vertically when hovering over one of the icons. How can I fix it?

Turnip

Don't transition the font-size. Use scale(). This will not effect surrounding elements.

If you move the transition to the default state, rather the the :hover state you won't get that "snap" back to the default size.

<script src="https://use.fontawesome.com/a63c918c5b.js" type="text/javascript">
</script>

<style media="screen" type="text/css">
  .icons {
    position: relative;
    padding: 9px;
    transition: transform 0.2s;
  }
  .icons:hover {
    color: #4f5255;
    transform: scale(1.3);
  }
  div {
    height: 100px;
    width: 200px;
    float: left;
  }
</style>



<div>
  <a target="_blank" href="link" class="icons fa fa-facebook" style="color: #4f5255;text-decoration:none;"></a>
  <a target="_blank" href="link" class="icons fa fa-twitter" style="color: #4f5255;text-decoration:none"></a>
  <a target="_blank" href="link" class="icons fa fa-instagram" style="color: #4f5255;text-decoration:none"></a>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Affect another div when hovering CSS

Display DIV when hovering another DIV's child CSS

CSS hovering with in a child div

strange CSS / Javascript behavior when hovering over TEXTAREA or A objects

CSS div that appears when hovering on anchor; keeping it visible while hovering over div

How to trigger div visibility when hovering over list item in CSS?

Move background image while hovering div

element of list must not move when hovering in primefaces

Is there a way to change a target div's text when hovering over other div's using css only?

change css of one div by hovering on another div

How to display a div when hovering over an image using CSS/HTML + Transitions?

Hover CSS : Changing button properties when hovering the whole div, not just the button

How to show div when hovering dynamically a link?

Displaying button when hovering over div in TailwindCSS

Hovering a div when on datatables header cell

Changing divs when hovering over a different div

Add divs on top of an div, when hovering

unique sound when hovering multiple instance div

Change colors of spans when hovering parent div

Trying to get div element to move while hovering another one

Move div horizontally when scroll vertically ( jquery or CSS3)

How to move a div when a checkbox is checked in .html/.css

how to move div in css

How to change css of img when hovering parent

css transition - issue when hovering on the element

Change css class when hovering html element

CSS: Border on top of navigation item when hovering

Keep css hover effect, when no longer hovering

CSS Animation on Menu item is not working when hovering

TOP Ranking

HotTag

Archive