Reza San Reza San - 2 months ago 14
CSS Question

Reveal div in inline position

Trying to slide reveal a div but it seems there's a jitter or div won't be inline due to the display:block or something. What I want is when I click Share button, the div with social-icon reveals smoothly beside Share button. Someone please shed some light. Thanks in advance.

Codepen: http://codepen.io/rezasan/pen/XjgppW

Snippet Example below



$('.social').click(function(){
$('.social-icons').toggle("slide");
});

.social {
display: inline-block;
height: 47px;
color: #58585b;
text-transform: uppercase;
font-size: 14px;
line-height: 47px;
padding: 0px 20px;
border: 1px solid rgba(88,88,91,0.5);
transition:width .2s ease;
-webkit- transition:width .2s ease;
}

.social-icons {
display: inline-block;
height: 47px;
color: #58585b;
font-family: "freight-text-pro",sans-serif;
text-transform: uppercase;
font-size: 14px;
line-height: 47px;
padding: 0px 20px;
border: 1px solid rgba(88,88,91,0.5);
margin-left: -5px;
display:none;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="social">
<a>SHARE</a>
</div>
<div class="social-icons">
<a>FB</a>
<a>TW</a>
<a>G+</a>
<a>WS</a>
</div>




Answer

Update Css Using Float:left.

$('.social').click(function(){
    $('.social-icons').toggle("slide");
});
.social {
    display: inline-block;
    height: 47px;
    color: #58585b;
    text-transform: uppercase;
    font-size: 14px;
    line-height: 47px;
    padding: 0px 20px;
    border: 1px solid rgba(88,88,91,0.5);
    transition: width .2s ease;
    float: left;
}
.social-icons {
    display: inline-block;
    height: 47px;
    color: #58585b;
    font-family: "freight-text-pro",sans-serif;
    text-transform: uppercase;
    font-size: 14px;
    line-height: 47px;
    padding: 0px 20px;
    border: 1px solid rgba(88,88,91,0.5);
    /* margin-left: -5px; */
    display: none;
    float: left;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="social">
    <a>SHARE</a>
</div>
<div class="social-icons">
    <a>FB</a>
    <a>TW</a>
    <a>G+</a>
    <a>WS</a>
</div>

Comments