css3 - Maintain list dimensions with CSS Transition -


i'm trying create effect list items in unordered list.

basically, anytime 1 hovers on list, size adjusts 2px in padding. while effecting overall dimensions of list item, pushing other list elements right , pushing div beaneath down 2px. know of way remedy issue?

all want list item during hover increase padding 2px without effecting other elements around it.

you can find code on jsfiddle here below:

html

<div id="info">     <ul class="projects">         <li class="site wmhr"><a href="#">$</a>              <p>what's hourly rate</p>         </li>         <li class="site proud"><a href="#">p</a>              <p>proud</p>         </li>         <li class="site mdy"><a href="#">m</a>              <p>manda dougherty yoga</p>         </li>         <li class="site rr"><a href="#">r</a>              <p>responsive resume</p>         </li>         <li class="site dp"><a href="#">d</a>              <p>designpairs (in progress)</p>         </li>     </ul> </div> 

css

.projects {     margin: 0;     padding: 0 0 50px 0; } .projects li {     display: inline-block;     list-style: none;     width: 70px;     height: 70px;     margin: 50px 20px 20px 0;     border: 4px solid #555;     border-radius: 50%;     font-size: 2em;     text-align: center;     line-height: 70px;     background: #414141;     -webkit-transition: .2s ease;     -moz-transition: .2s ease;     -ms-transition: .2s ease;     -o-transition: .2s ease;     transition: .2s ease; } .projects p {     font-size: .850rem;     line-height: 1.500em; } .projects li:hover {     padding: 2px;     display: inline-block;     list-style: none;     border-radius: 50%;     line-height: 71px; } .projects li {     font-family:'montserrat', sans-serif;     color: #fff;     text-decoration: none; } .wmhr:hover {     background: #66cc6e;     border: 4px solid #57ac5e; } .proud:hover {     background: #5882c2;     border: 4px solid #4b6da2; } .mdy:hover {     background: #fec601;     border: 4px solid #ddad03; } .rr:hover {     background: #797b96;     border: 4px solid #606176; } .dp:hover {     background: #475161;     border: 4px solid #38404d; } 

if don't want item move, have counteract padding reduction in other dimension or change layout structure not use inline layout.

here's version of jsfiddle uses reduction in margin counteract increase in padding. hovered item gets larger, other items don't move.

.projects li:hover {     padding: 2px;     display: inline-block;     list-style: none;     border-radius: 50%;     line-height: 71px;     margin: 48px 18px 18px 0; } 

note, changed default left margin 2px reduce 0 here hate using negative margins (they cause objects overlap can introduce unexpected behaviors).

http://jsfiddle.net/jfriend00/6jjcg/


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -