3
votes

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>
4

4 Answers

5
votes

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>
4
votes

Change the display properties of .social,.social-icons to float:left. Heres the working Fiddle

0
votes

Change

display: inline-block;

to

float: left;
0
votes

I'm not saying I agree with your technique, but this should do the trick:

.social{
  display: block;
  width:46px;
  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);
  transition:width .2s ease;
  -webkit- transition:width .2s ease;
  float:left;
}

.social-icons{
  display:none;
  width:100px;
  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: 88px;
}