Skip to content

Instantly share code, notes, and snippets.

@nladart
Created September 6, 2013 07:10
Show Gist options
  • Save nladart/6460489 to your computer and use it in GitHub Desktop.
Save nladart/6460489 to your computer and use it in GitHub Desktop.
Animated swinging panels/grid

Animated swinging panels/grid

An idea for a dashboard type page or something. Pure css. JS is only used to bypass the transition on page load. Still needs work.

A Pen by Seth Abbott on CodePen.

License.

<div class="wrapper preload">
<section class="grid-unit top-left">
<div class="swing-panel">
<span class="desc">What does this guy think he is doing?</span>
</div>
<div class="sphere">
<span class="entypo-book-open icon"></span>
</div>
</section>
<section class="grid-unit top-right">
<div class="swing-panel">
<span class="desc">This pen is the worst thing I have even seen!</span>
</div>
<div class="sphere">
<span class="entypo-chat icon"></span>
</div>
</section>
<section class="grid-unit bottom-left">
<div class="swing-panel">
<span class="desc">Whatever, I'm going to get a beer!</span>
</div>
<div class="sphere">
<span class="entypo-tools icon"></span>
</div>
</section>
<section class="grid-unit bottom-right">
<div class="swing-panel">
<span class="desc">One does not simply animate panels.</span>
</div>
<div class="sphere">
<span class="entypo-picture icon"></span>
</div>
</section>
</div><!-- end wrapper -->
jQuery(function(){
$(window).load(function(){
$('.wrapper').removeClass('preload');
});
});
@import url(http://fonts.googleapis.com/css?family=Oxygen);
@import url(http://weloveiconfonts.com/api/?family=entypo);
[class*="entypo-"]:before {
font-family: 'entypo', sans-serif;
}
* {
box-sizing: border-box;
}
.preload * {
transition: none !important;
}
html
{
position: relative;
min-height: 100%;
}
body {
background: #fff;
}
body,
.wrapper{
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
.grid-unit {
position: relative;
float: left;
border-top: 10px solid #fff;
border-left: 10px solid #fff;
width: 50%;
height: 50%;
perspective: 500;
overflow: hidden;
}
.top-left {
background: rgba(236,208,120,1);
}
.top-right {
background: rgba(217,91,67,1);
border-right: 10px solid #fff;
}
.bottom-right {
background: rgba(192,41,66,1);
border-bottom: 10px solid #fff;
border-right: 10px solid #fff;
}
.bottom-left {
background: rgba(84,36,55,1);
border-bottom: 10px solid #fff;
}
.swing-panel {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
font-size: 2.5em;
color: #fff;
font-family: Oxygen, arial, sans-serif;
transform-origin: left 50%;
transform: rotateY(120deg);
transition: transform .5s ease;
letter-spacing: -.05em;
text-shadow: 0 1px 0 rgba(0,0,0,.2);
}
.top-right .swing-panel,
.bottom-right .swing-panel{
transform-origin: right 50%;
transform: rotateY(-120deg);
}
.desc {
display: block;
position: absolute;
padding: 5%;
}
.top-left .desc {
top: 0;
left: 0;
}
.top-right .desc {
top: 0;
right: 0;
}
.bottom-left .desc {
bottom: 0;
left: 0;
}
.bottom-right .desc {
bottom: 0;
right: 0;
}
.grid-unit:hover .swing-panel {
transform: rotateY(0deg);
}
.sphere {
position: absolute;
width: 200px;
height: 200px;
background-color: rgba(255,255,255,1);
border-radius: 500px;
transition: background-color .25s ease;
opacity: 1;
}
.top-left .sphere {
right: -100px;
bottom: -100px;
}
.top-right .sphere {
left: -100px;
bottom: -100px;
}
.bottom-right .sphere {
left: -100px;
top: -100px;
}
.bottom-left .sphere {
right: -100px;
top: -100px;
}
.grid-unit:hover .sphere {
background-color: rgba(255,255,255,0);
}
.icon {
position: absolute;
font-size: 2.5em;
transition: color .25s ease;
}
.bottom-left .icon {
bottom: 18%;
left: 18%;
color: rgba(84,36,55,1);
}
.bottom-right .icon {
bottom: 18%;
right: 18%;
color: rgba(192,41,66,1);
}
.top-right .icon {
top: 18%;
right: 18%;
color: rgba(217,91,67,1);
}
.top-left .icon {
top: 18%;
left: 18%;
color: rgba(236,208,120,1);
}
.swing-panel:hover .icon {
color: #fff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment