Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to block the width extension of sibling elements when creating a hover with a css transition

I need to increase the width of a list of elements when I hover over a certain element using a CSS transition.
The CSS functionality works, but the problem is that the hover moves the sibling elements. How can this problem be overcome with CSS?

.aside-menu__element {
  width: 68px;
  height: 68px;
  background-color: #999;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 1s;
}

.aside-menu__element:hover {
  background-color: green;
  border-radius: 20px;
  width: 300px;
}
<div class="aside-menu">
  <div class="aside-menu__element"><i class="fa-solid fa-arrow-up-long"></i></div>
  <div class="aside-menu__element"><i class="fa-solid fa-arrow-right-long"></i></div>
  <div class="aside-menu__element"><i class="fa-solid fa-arrow-left-long"></i></div>
</div>

The link below shows the HTML and CSS code I used: codepen

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

just add this code

.aside-menu { 
  position:fixed;
  right:50px;
  top:150px;
  display: flex;    
  align-items: flex-end;
  flex-direction: column;
}

working sample codepen

.aside-menu {
    position:fixed;
    right:50px;
    top:0px;
   display: flex;    
  align-items: flex-end;
  flex-direction: column;
}

.aside-menu__element {
     width: 68px;
    height: 68px;
    background-color: #999;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 1s;
}

.aside-menu__element:hover {
    background-color: green;
    border-radius: 20px;
    width: 300px;
}
<div class="aside-menu">
  <div class="aside-menu__element"><i class="fa-solid fa-arrow-up-long"></i></div>
    <div class="aside-menu__element"><i class="fa-solid fa-arrow-right-long"></i></div>
    <div class="aside-menu__element"><i class="fa-solid fa-arrow-left-long"></i></div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading