JSFiddle - React, Tailwind, and code Playground
by lukempeters
HTML
<h1><strong>Super Buttons</strong> - <small>by <a href="http://www.lukepeters.me">Luke Peters</a></small></h1>
<div class="clearBoth"></div>
<div class="button blue">
<div class="text">
<b>Super</b> Button
</div>
<div class="hidden">
<p>You're reading this message because it is your destiny. And guess what else!</p>
<p>You're reading this message because it is your destiny. And guess what else!</p>
<p>This is a second paragraph!</p>
</div>
</div>
<div class="button red">
<div class="text">
<b>Super</b> Button
</div>
<div class="hidden">
<p>You're reading this message because it is your destiny.</p>
</div>
</div>
<div class="button green">
<div class="text">
<b>Super</b> Button
</div>
<div class="hidden">
<p>You're reading this message because it is your destiny. And guess what else!</p>
<p>This is a second paragraph!</p>
</div>
</div>
<div class="clearBoth"></div>
<div class="button yellow">
<div class="text">
<b>Super</b> Button
</div>
<div class="hidden">
<p>You're reading this message because it is your destiny. And guess what else!</p>
<p>This is a second paragraph!</p>
</div>
</div>
<div class="button purple">
<div class="text">
<b>Super</b> Button
</div>
<div class="hidden">
<p>You're reading this message because it is your destiny. And guess what else!</p>
<p>This is a second paragraph!</p>
</div>
</div>
<div class="button grey">
<div class="text">
<b>Super</b> Button
</div>
<div class="hidden">
<p>You're reading this message because it is your destiny. And guess what else!</p>
<p>This is a second...
CSS
body {
margin: 0;
padding: 0;
font-family: Verdana, Tahoma, Arial;
font-size: 12px;
background: #555555;
}
h1 {
margin: 0 0 16px 0;
padding: 7px 10px 10px 10px;
font-family: Verdana, Tahoma, Arial;
font-size: 20px;
font-weight: normal;
text-shadow: 1px 1px 0 #000000;
color: #eeeeee;
border-bottom: 1px solid #666666;
background: #222222;
}
h1 small {
font-size: 14px;
}
a, a:visited {
color: #eeeeee;
}
a:hover {
color: #ffffff;
}
.clearBoth {
clear: both;
}
.text {
margin: 0;
display: inline-block;
}
.hidden {
padding: 4px 0 1px 0;
min-width: 110px;
font-size: 11px;
display: none;
}
.hidden p {
margin: 0 0 10px 0;
}
.button {
position: relative;
float: left;
margin: 0 0 12px 12px;
padding: 7px 18px 8px 18px;
border-left: 1px solid rgba(255,255,255,0.3);
-moz-border-radius: 18px 7px 18px 7px;
-webkit-border-radius: 18px 7px 18px 7px;
border-radius: 18px 7px 18px 7px;
color: rgba(0,0,0,0.8);
text-shadow: 0 1px 0 rgba(255,255,255,0.2);
display: inline-block;
-moz-box-shadow: 0 1px 2px rgba(0,0,0,0.6);
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.6);
box-shadow: 0 1px 2px rgba(0,0,0,0.6);
cursor: pointer;
overflow: hidden;
background-image: url('http://lukepeters.me/gradient.png');
background-position: 0 0;
background-repeat: repeat-x;
}
.button:hover {
-moz-box-shadow: 0 1px 4px rgba(0,0,0,0.6);
-webkit-box-shadow: 0 1px 4px rgba(0,0,0,0.6);
box-shadow: 0 1px 4px rgba(0,0,0,0.6);
background-image: url('http://lukepeters.me/gradient.png');
background-position: 0 0;
background-repeat: repeat-x;
}
.blue {
background-color: #6AC6FC;
}
.blue:hover {
background-color: #a4ddff;
}
.red {
background-color: #ff4a4a;
}
.red:hover {
background-color: #ff6666;
}
.green {
background-color: #6cff3f;
}
.green:hover {
background-color:...
JavaScript
$('.button').hover(function() {
var txtWidth = $(this).children('.text').width();
var txtHeight = $(this).children('.text').height();
//alert(txtWidth + '<br />' + txtHeight);
$(this).css('width', txtWidth+'px');
$(this).css('height', txtHeight+'px');
$(this).children('.hidden').css('display', 'block').stop().animate({
'opacity': '1'
}, 200);
var hiddenWidth = $(this).children('.hidden').width();
var hiddenHeight = txtHeight + $(this).children('.hidden').height() + 'px';
$(this).stop().animate({
'width': hiddenWidth,
'height': hiddenHeight
}, 200);
}, function(){
var txtWidth2 = $(this).children('.text').width() + 'px';
var txtHeight2 = $(this).children('.text').height() + 'px';
$(this).children('.hidden').stop().animate({
'opacity': '0'
}, 200);
$(this).stop().animate({
'width': txtWidth2,
'height': txtHeight2
}, 200);
});