Issues in slideout control UI - css

I am bit new to CSS/bootstrap style programming.
I am trying to create a SlideOut control. Please refer the working code in URL .
I am facing some issues as listed below
I am not able to get the curve on the left side of the button i.e. Top-Left and Bottom-Left (Please refer snapshot)
I want to increase the size of the Feedback area i.e. want to have the height and width as 500px each. But When I try chaning it in the CSS #slideout_inner, the slide out doesn't happen properly/smoothly.
I want to implement this slideout control using HTML and CSS/bootstrap only and don't want to use JQuery in it.
Can anyone please help me with this issues?
Space getting added inbetween the Button and the innerarea,

Border:
turn your border radius around
It should be like this
border-radius: 5px 0 0 5px;
/* here is the pattern */
border-radius: top-right top-left bottom-left bottom-right
Sizing:
You have to change the sizing in 3 places
#slideout:hover {
right: here;
}
#slideout_inner textarea {
display: block;
margin: 15px;
width: here;
height: 200px;
}
#slideout_inner textarea {
width: here;
height: 100px;
margin-bottom: 6px;
}
Demo:
#slideout {
position: fixed;
top: 40px;
right: 0;
width: 35px;
padding: 12px 0;
text-align: center;
background: #6DAD53;
-webkit-transition-duration: 0.3s;
-moz-transition-duration: 0.3s;
transition-duration: 0.3s;
-o-transition-duration: 0.3s;
-webkit-border-radius: 5px 0 0 5px;
-moz-border-radius: 5px 0 0 5px;
border-radius: 5px 0 0 5px;
}
#slideout_inner {
position: fixed;
top: 40px;
right: -550px;
background: #6DAD53;
width: 500px;
padding: 25px;
height: 130px;
-webkit-transition-duration: 0.3s;
-moz-transition-duration: 0.3s;
transition-duration: 0.3s;
-o-transition-duration: 0.3s;
text-align: right;
-webkit-border-radius: 0 0 0 5px;
-moz-border-radius: 0 0 0 5px;
border-radius: 0 0 0 5px;
}
#slideout_inner textarea {
width: 490px;
height: 100px;
margin-bottom: 6px;
}
#slideout:hover {
right: 550px;
}
#slideout:hover #slideout_inner {
right: 0;
}
<div id="slideout">
<img src="http://img.usabilitypost.com.s3.amazonaws.com/1104/css_slideout/feedback.png" alt="Feedback" />
<div id="slideout_inner">
<form>
<textarea></textarea>
<input type="submit" value="Post feedback">
</form>
</div>
</div>

Related

How to make an image show over an element's padding region in CSS?

Current Situation Image
Here is what I have got. But I want that rectangle facebook image behind the red region (currently it is just behind the text 'Please')
#mlnk{
text-decoration:none;
position:relative;
top:40%;
left:0%;
color: #b5c5d6;
}
.container-corner-img{ /* **THIS IS TO BE PUSHED BACK** */
height: 40%; width: 70%;
position: absolute;
top: 5px; left:-75px;
}
.container{
width:50%;
height:30%;
background: linear-gradient(#8B9DC1, #3b5998);
padding:100px;
border-radius:12px;
position: relative;
font-family: sans-serif;
}
h1{ /* **THIS NEEDS TO BE BROUGHT TO FRONT** */
margin-left: auto;
margin-right: auto;
padding: 8px;
border-radius: 4px;
box-shadow: 0 4px 6px 0 rgba(0,0,0,0.2);
transition: 0.4s ease;
background-color: red;
margin-top: 0;
}
img{
height: 80%;
width: 50%;
}
<div class="container">
<div class="container-corner-img">
<img src="fbminimal.png">
</div>
<h1>
<a id="mlnk" href = "#link"> Please login to your facebook account first</a>
</h1>
</div>
I have commented the css definitions in CAPS that needs to be focused according to me.
To bring the heading to the front, you have to set z-index to a larger value. To be able to use z-index on an element it needs to have a different position than static. So use relative. Moreover, do not use the center-tag since it is deprecated. The layout should be controlled by CSS only.
#mlnk {
text-decoration: none;
position: relative;
top: 40%;
left: 0%;
color: #b5c5d6;
}
h3 {
color: midnightblue;
padding: 4px;
box-shadow: 0 2px 4px 0 #38434e;
background: #3c64ad;
}
.container-corner-img {
/* **THIS IS TO BE PUSHED BACK** */
height: 40%;
width: 70%;
position: absolute;
top: 5px;
left: -75px;
/* opacity: 0.4; */
}
.container {
width: 50%;
height: 30%;
background: linear-gradient(#8B9DC1, #3b5998);
padding: 100px;
border-radius: 12px;
position: relative;
font-family: sans-serif;
/* z-index: 1; */
margin: 0 auto;
}
h1 {
/* **THIS NEEDS TO BE BROUGHT TO FRONT** */
margin-left: auto;
margin-right: auto;
padding: 8px;
border-radius: 4px;
box-shadow: 0 4px 6px 0 rgba(0, 0, 0, 0.2);
transition: 0.4s ease;
background-color: red;
/* rgba(0,0,80,0.2); */
margin-top: 0;
/* Add this */
position: relative;
z-index: 1000;
}
h1:hover {
box-shadow: 0 4px 6px 0 rgba(0, 0, 0, 0.2), 0 6px 8px 0 rgba(0, 0, 0, 0.19);
transition: 0.4s ease;
}
img {
height: 80%;
width: 50%;
/* z-index: 0; */
}
.center {
text-align: center;
margin: 0 auto;
}
<div class="center">
<div class="container">
<div class="container-corner-img">
<img src="https://stocknews.com/wp-content/uploads/2017/07/facebook-fb-alternate.jpg">
</div>
<h1>
<a id="mlnk" href="#link"> Please login to your facebook account first</a>
</h1>
<h3>You need to Log In</h3>
</div>
</div>

Make a div at least as tall as the page

Here is a restricted code pen containing the problem code: http://codepen.io/Jraghon/pen/YqgKYR
I'm trying to make a fixed, mobile-first, resonsive header. I have everything working, except for some sizing issues. Specifically, I want the div that actually holds the content to be at least as high as the viewport minus the size of the header.
I have ensured that all of the div's ancestors have height: 100%. Moreover, js shows that they are all the correct height. However, the dc-container is not as tall as it should be, and I can't figure out why.
Answer
For lack of a better answer, I am using the answer from this question (although I wish there were a way to make it stretch without tables):
Make nested div stretch to 100% of remaining container div height
Here is the final pen: http://codepen.io/Jraghon/pen/pyYojr
The problem is that you have a circular definition:
.site-content {
min-height: calc(100% - 66px);
height: auto; /* Depends on contents */
}
.site-content > .dc-container {
height: 100%; /* Depends on parent */
min-height: 100%; /* Depends on parent */
}
Instead, you should use
.site-content {
height: calc(100% - 66px);
}
.site-content > .dc-container {
height: auto;
min-height: 100%;
}
$(document).ready(function() {
$('#header__icon').click(function(e) {
e.preventDefault();
$('body').toggleClass('with--sidebar');
gooo();
});
$('#site-cache').click(function(e) {
$('body').removeClass('with--sidebar');
gooo();
});
});
function gooo() {
$('.x0').html('html x: ' + $('html').outerWidth());
$('.x1').html('html y: ' + $('html').outerHeight());
$('.x2').html('body x: ' + $('body').outerWidth());
$('.x3').html('body y: ' + $('body').outerHeight());
$('.x4').html('site-container x: ' + $('.site-container').outerWidth());
$('.x5').html('site-container y: ' + $('.site-container').outerHeight());
$('.x6').html('site-pusher x: ' + $('.site-pusher').outerWidth());
$('.x7').html('site-pusher y: ' + $('.site-pusher').outerHeight());
$('.x8').html('header dc-container x: ' + $('.header .dc-container').outerWidth());
$('.x9').html('header dc-container y: ' + $('.header .dc-container').outerHeight());
$('.x10').html('site-content x: ' + $('.site-content').outerWidth());
$('.x11').html('site-content y: ' + $('.site-content').outerHeight());
$('.x12').html('content dc-container x: ' + $('.site-content .dc-container').outerWidth());
$('.x13').html('content dc-container y: ' + $('.site-content .dc-container').outerHeight());
}
$(function() {
$(window).resize(gooo).trigger('resize');
});
/* VARIABLES */
html,
body {
font-family: 'Roboto', sans-serif;
line-height: 1.4;
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.site-container {
height: 100%;
}
.site-pusher {
height: 100%;
position: absolute;
left: 0;
right: 0;
bottom: 0;
-moz-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
}
.dc-container {
overflow: hidden;
*zoom: 1;
margin: auto;
width: 100%;
max-width: 960px;
height: 100%;
}
.header {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 66px;
line-height: 66px;
-moz-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
}
.header .dc-container {
color: #fff;
background-color: #0288D1;
}
.site-content {
margin-top: 66px;
height: calc(100% - 66px);
}
.site-content .dc-container {
height: auto;
min-height: 100%;
background-color: #B3E5FC;
}
.header__logo {
color: #fff;
font-weight: 700;
padding: 0 25px;
float: left;
}
.menu {
position: fixed;
left: -250px;
top: 0;
bottom: 0;
width: 250px;
background-color: #0277BD;
-moz-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
}
.menu a {
padding: 0 10px;
color: #fff;
height: 40px;
text-align: center;
line-height: 40px;
display: block;
border-bottom: 1px solid #0288D1;
}
.menu a:hover {
color: #B3E5FC;
}
.header__icon {
position: relative;
display: block;
float: left;
width: 50px;
height: 66px;
cursor: pointer;
}
.header__icon:after {
content: '';
position: absolute;
display: block;
width: 1rem;
height: 0;
top: 26px;
left: 15px;
-moz-box-shadow: 0 0px 0 1px #fff, 0 6px 0 1px #fff, 0 12px 0 1px #fff;
-webkit-box-shadow: 0 0px 0 1px #fff, 0 6px 0 1px #fff, 0 12px 0 1px #fff;
box-shadow: 0 0px 0 1px #fff, 0 6px 0 1px #fff, 0 12px 0 1px #fff;
}
.site-cache {
position: fixed;
top: 0;
bottom: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.6);
-moz-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
}
.with--sidebar {
overflow: hidden;
}
.with--sidebar .header,
.with--sidebar .site-pusher {
left: 250px;
right: -250px;
}
.with--sidebar .menu {
left: 0;
}
.with--sidebar .site-cache {
right: 0;
left: 250px;
}
<div class="site-container">
<div class="site-pusher">
<header class="header">
<div class="dc-container">
<a href='#' class="header__logo" id='header__logo'><b>LOGO</b></a>
<nav class="menu">
Home
About
Blog
Contact
</nav>
</div>
</header>
<div class="site-content">
<div class="dc-container">
<div class="x0"></div>
<div class="x1"></div>
<br>
<div class="x2"></div>
<div class="x3"></div>
<br>
<div class="x4"></div>
<div class="x5"></div>
<br>
<div class="x6"></div>
<div class="x7"></div>
<br>
<div class="x8"></div>
<div class="x9"></div>
<br>
<div class="x10"></div>
<div class="x11"></div>
<br>
<div class="x12"></div>
<div class="x13"></div>
</div>
<!-- END container -->
</div>
<!-- END site-content -->
<div class="site-cache" id="site-cache"></div>
</div>
<!-- END site-pusher -->
</div>
<!-- END site-container -->
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
You can use viewport sizes. vw means viewport width, and vh viewport height:
.selector {
height: 100vh; /** 100% of viewport height **/
}
You can use calc() to substract the height of the header:
.header {
height: 50px;
}
.selector {
height: calc(100vh - 50px); /** 100% of viewport height - 50 px header height **/
}

Css button box-shadow transition

I'm having some trouble with making an transition effect on a button.
Using "box-shadow" I am able to create this:
.load {
color:black;
border:none;
background-color: #ffffff;
width: 100px;
height: 30px;
margin-left: 21px;
box-shadow: inset 0 0 0 0 #000000;
transition-duration: 0.3s;
transition-timing-function: ease-in;
}
.load:hover {
transition-duration: 0.3s;
box-shadow: inset 0 -3px 0 0 #000000;
}
<button class="load"> Home
</button>
The shadow comes from the bottom and 3px into the button. I want it to be able to come from left to right, but still remaining at the 3px height.
I'm also pretty sure this website got it working, but i'm not able to extract the required CSS from inspecting it.
Website
Thanks!
You can do this using the :after attribute. See my example below. The width of the after element changes between 0 and 100% to get the effect. You can tweak the settings of .home-link:after easily to your needs.
Using only box-shadow is not the best way and surely not the best practise for this effect.
.home-link {
position: relative;
background: none;
border: none;
font-size: 1em;
color: blue;
width: 80px;
text-align: center;
margin: 0;
padding: 0;
}
.home-link:after {
position: absolute;
bottom: 0;
content: '';
display: block;
width: 0;
height: 3px;
background: #000;
-webkit-transition: width .2s ease-in-out;
transition: width .2s ease-in-out;
}
.home-link:hover:after {
width: 100%;
}
<button class="home-link">Home</button>

CSS3 animation is not working in IE11 but works in other browsers

I have created a CSS3 animation on a button. At the moment, it works perfectly everywhere apart from IE. I know it wont work well in older IE versions, but I was atleast expecting it to work in IE11.
I have created a fiddle to demonstrate Fiddle
I call the animation on :before and :after like so
animation: 1000ms ease 0s normal none infinite running pulse-long;
If you open the fiddle in Firefox or Chrome, you should see the animation on the button working. If you open it in IE11, it is just a static dot. I have gone online and tried a few things, such as moving the animation frames to the top of the CSS file, but it still does not work.
Is there any way to get this animation working in IE11?
There are two things that are preventing the animation from working in IE11 and they are as follows:
IE11 always has a problem when setting animation-play-state as running in the shorthand. There is no justification for this and it should probably be considered as a bug. Fix for this issue should be to just remove the running from the shorthand. This will cause no harm because the default value for animation-play-state is running.
The parent button container's dimension is only 10px x 10px whereas the pseudo-elements are eventually getting a dimension of 60px x 60px during the animation. While other browsers are by defaulting showing the overflow, IE11 seems to be cropping it. This needs to be cross-checked with the specs to find out if it is a bug or something that is loosely defined.
The fix for the overflow issue is again pretty simple. Just add a overflow: visible for the button container (.btnPulse.inactive). This will also not cause any problem in other browser because they are anyway doing this by default.
Snippet showing the overflow problem:
In the below snippet, I have avoided the animations and just added a couple of default box-shadow to the pseudo-elements such that the whole thing looks like 4 concentric circles with a red colored circle (produced by the button element) in the middle, followed by a white circle (blank space), followed by a blue colored circle (produced by box shadow of :before element) and then a green circle (produced by box shadow of :after element).
In Chrome, Firefox and Opera the concentric circles would be visible completely but IE11 will show only the center red circle because the rest is outside parent's area.
.btnPulse.inactive.throb::before {
box-shadow: 0 0 0 16px blue inset;
display: block;
height: 60px;
left: -22px;
margin: 0 auto;
right: 0;
top: 50%;
transform: translate3d(-3px, -50%, 0px);
width: 60px;
}
.btnPulse.inactive::before {
border-radius: 100%;
bottom: -5px;
box-shadow: 0 0 0 1px red inset;
content: "";
display: block;
height: 30px;
left: -10px;
margin: 0 auto;
position: absolute;
right: -5px;
top: -5px;
transition: all 300ms ease-in-out 0s;
width: 30px;
}
.btnPulse.inactive.throb::after {
border-radius: 100%;
bottom: -5px;
box-shadow: 0 0 0 8px green inset;
content: "";
display: block;
height: 60px;
left: -22px;
margin: 0 auto;
position: absolute;
right: -5px;
top: 50%;
transform: translate3d(-2px, -50%, 0px);
transition: all 300ms ease-in-out 0s;
width: 60px;
}
.btnPulse.inactive {
background: red none repeat scroll 0 0;
border: medium none;
border-radius: 100%;
height: 10px;
outline: medium none;
padding: 0;
position: relative;
width: 10px;
}
.btnPulse {
border-radius: 50%;
cursor: pointer;
height: 15px;
padding: 0;
transition: all 300ms ease-in-out 0s;
width: 15px;
}
.btn {
-moz-user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
display: inline-block;
font-size: 14px;
font-weight: 400;
line-height: 1.42857;
margin-bottom: 0;
padding: 6px 12px;
text-align: center;
vertical-align: middle;
white-space: nowrap;
}
#button-container {
position: absolute;
left: 100px;
top: 100px;
}
<div id="button-container">
<button class="btn btnPulse inactive throb"></button>
</div>
Working Snippet with the fix:
The below snippet has both the above mentioned fixes applied and it works in IE11, Chrome, Firefox and Opera.
#keyframes pulse-short {
100% {
box-shadow: inset 0 0 0 80px red;
-moz-box-shadow: inset 0 0 0 80px red;
-webkit-box-shadow: inset 0 0 0 80px red;
height: 60px;
width: 60px;
left: -22px;
opacity: 0;
}
}
#keyframes pulse-long {
100% {
box-shadow: inset 0 0 0 10px red;
-moz-box-shadow: inset 0 0 0 10px red;
-webkit-box-shadow: inset 0 0 0 10px red;
height: 60px;
width: 60px;
left: -22px;
opacity: 0;
}
}
.btnPulse.inactive.throb::before {
animation: 1000ms ease 0s normal none infinite pulse-long;
box-shadow: 0 0 0 0 red inset;
display: block;
height: 100%;
left: 3px;
margin: 0 auto;
right: 0;
top: 50%;
transform: translate3d(-3px, -50%, 0px);
width: 100%;
}
.btnPulse.inactive::before {
border-radius: 100%;
bottom: -5px;
box-shadow: 0 0 0 1px red inset;
content: "";
display: block;
height: 30px;
left: -10px;
margin: 0 auto;
position: absolute;
right: -5px;
top: -5px;
transition: all 300ms ease-in-out 0s;
width: 30px;
}
.btnPulse.inactive.throb::after {
animation: 2500ms ease 300ms normal none infinite pulse-short;
border-radius: 100%;
bottom: -5px;
box-shadow: 0 0 0 0 red inset;
content: "";
display: block;
height: 30px;
left: -9px;
margin: 0 auto;
position: absolute;
right: -5px;
top: 50%;
transform: translate3d(-2px, -50%, 0px);
transition: all 300ms ease-in-out 0s;
width: 30px;
}
.btnPulse.inactive {
background: red none repeat scroll 0 0;
border: medium none;
border-radius: 100%;
height: 10px;
outline: medium none;
padding: 0;
position: relative;
width: 10px;
overflow: visible;
}
.btnPulse {
border-radius: 50%;
cursor: pointer;
height: 15px;
padding: 0;
transition: all 300ms ease-in-out 0s;
width: 15px;
}
.btn {
-moz-user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
display: inline-block;
font-size: 14px;
font-weight: 400;
line-height: 1.42857;
margin-bottom: 0;
padding: 6px 12px;
text-align: center;
vertical-align: middle;
white-space: nowrap;
}
#button-container {
position: absolute;
left: 100px;
top: 100px;
}
<div id="button-container">
<button class="btn btnPulse inactive throb"></button>
</div>
IE 10 and 11 need css animation without webkit. like shown below.
#keyframes animation{
0%{width: 10px; height:10px; border-radius:5px; background:#bfbfbf;}
}
#element{animation: animation 2s ease-in-out 0s infinite alternate;}
This works for me finally.

CSS3 Transition: Animate child to 100% width, parent jumps to 100% width instantly

I am trying to create a delete button, that once you click it, expands to show the delete option, so you won't delete anything by mistake. The problem is that the parent container jumps to full size right away while I would like it to grow gradually.
This can be overcome when I set the fixed pixel width for the parent container, but the problem is that I don't always know the width of the contents. Therefor I used a percentage to get it dynamic.
I don't really know how to explain it clearly so I've made a fiddle to show you: http://jsfiddle.net/cgHcP/
HTML:
<div class="right">
<div style="background-color: #000; display: inline-block;">
<div class="roll-button">
<div class="icon">x</div>
<div class="text">Remove</div>
</div>
</div>
<div style="background-color: #000; display: inline-block;">
<div class="roll-button">
<div class="icon">x</div>
<div class="text">Remove</div>
</div>
</div>
</div>
CSS:
/* Roll Button */
div.roll-button {
float: right;
display: inline;
position: relative;
height: 24px;
width: 24px;
-webkit-box-shadow: 0 0 0 2px #fff;
-webkit-border-radius: 12px;
text-align: center;
vertical-align: middle;
background-color: #fff;
overflow: hidden;
-webkit-transition: width .5s ease-in-out;
transition: width .5s ease-in-out;
}
div.roll-button .icon {
left: 0;
display: inline;
position: absolute;
font-size: 24px;
width: 24px;
height: 24px;
background-color: #ff3e3e;
-webkit-border-radius: 12px;
-webkit-transition: all .5s ease-in-out;
transition: all .5s ease-in-out;
text-align: center;
vertical-align: middle;
color: #fff;
line-height: .7;
}
div.roll-button .text {
float: left;
display: inline;
position: relative;
height: 24px;
overflow: hidden;
-webkit-transition: all .5s ease-in-out;
transition: all .5s ease-in-out;
vertical-align: middle;
line-height: 24px;
color: #ff3e3e;
font-weight: 700;
padding: 0 0 0 24px;
font-size: 12px;
}
div.roll-button:hover .text {
padding: 0 5px 0 29px;
}
div.roll-button:hover .icon {
-webkit-transform: rotateZ(-180deg);
}
div.roll-button:hover {
width: 100%;
}
.right {
float: right;
margin-right: 200px;
}
When you look at the fiddle, you'll notice the parent container (black), jumps to full size when hovered. Even though the child seems to grow gradually. This behavior causes trouble when you put multiple items inline (like in the fiddle, and exactly what I want to do).
I'm, trying to make this button purely with CSS, but this is where I get stuck. Does anyone have a suggestion how this can be done by using purely CSS?
The trick to achieving what you want is using width:auto on the .text and limiting the max-width of it.. the new working jsFiddle
div.roll-button .text {
width: auto;
max-width:0px;
}
div.roll-button:hover .text {
max-width:100px; /* set this to the maximum allowed value.. */
}
Ok, it seemed to much of a hassle to get this to work without using javascript, so I decided to go the javascript way using jQuery.
I now set the width in real pixels to bypass the problem that still occurs in most browsers when you make a transition from a pixel width to auto or percentage. I did it by creating a wrapper element with a overflow:hidden and summed up the width of the children. This sum I used to set the button width in real pixels.
Furthermore i've added a timer to close the button within a preset amount of time. My idea for this button was to not have to show a delete dialog asking if the content should really be deleted. Maybe this fiddle will be useful to someone else.
Check my latest fiddle for the final result.
HTML
<div class="roll-button">
<div class="icon">x</div>
<div class="label">Short Label</div>
</div>
<div class="roll-button">
<div class="icon">x</div>
<div class="label">This is a very long label</div>
</div>
CSS
body {
background-color: #ff3e3e;
}
.roll-button {
margin-right: 12px;
float: right;
display: inline-block;
width: 24px;
height: 24px;
overflow: hidden;
-webkit-transition: all .5s ease-in-out;
-moz-transition: all .5s ease-in-out;
-o-transition: all .5s ease-in-out;
transition: all .5s ease-in-out;
white-space: nowrap;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
background-color: rgba(255,255,255,1);
-webkit-box-shadow: 0 0 0 2px rgba(255,255,255,1);
-moz-box-shadow: 0 0 0 2px rgba(255,255,255,1);
box-shadow: 0 0 0 2px rgba(255,255,255,1);
}
.roll-button .icon {
display: inline-block;
-webkit-transition: all .5s ease-in-out;
-moz-transition: all .5s ease-in-out;
-o-transition: all .5s ease-in-out;
transition: all .5s ease-in-out;
width: 24px;
height: 24px;
background-color: #ff0000;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-webkit-box-shadow: 0 0 0 2px rgba(255,255,255,1);
-moz-box-shadow: 0 0 0 2px rgba(255,255,255,1);
box-shadow: 0 0 0 2px rgba(255,255,255,1);
text-align: center;
vertical-align: middle;
}
.roll-button .label {
display: inline-block;
height: 24px;
padding: 0 15px 0 5px;
}
.roll-button.open .icon {
-webkit-transform: rotateZ(-180deg);
}
javascript/jquery
$(function() {
$('.roll-button').bind('click',function() {
var iconWidth = $(this).find('.icon').outerWidth();
var newWidth = 0;
var timer = [];
var $elm = $(this);
$(this).children().each(function(){ newWidth += $(this).outerWidth(); });
if(!$(this).hasClass('open')) {
$(this).addClass('open').css({'width':newWidth+'px'});
setTimeout(function() {
$elm.removeClass('open').css({'width':iconWidth+'px'});
},5000);
}
});
});

Resources