Parent DIV Height to expand based on inner content [duplicate] - html

This question already has answers here:
Expanding a parent <div> to the height of its children
(20 answers)
Closed 8 years ago.
I'm trying to set the height of .background based on the number of .slice elements on the page. I know the inner elements being floated left doesn't help but I'm not sure how to solve this.
JSFiddle
http://jsfiddle.net/8ryAD/
HTML
<div class="master">
<a id="btn-nav">
<span></span>
<span>Menu</span>
<span></span>
</a>
<nav id="main-nav">
<div class="background">
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
<div class="slice"></div>
</div>
</nav>
</div><!-- end master -->
CSS
#import url(http://fonts.googleapis.com/css?family=Droid+Sans);
body {
background: #2980b9;
font-family: 'Droid Sans', sans-serif;
}
#btn-nav {
position:absolute;
left:10px;
top:10px;
width:30px;
height:30px;
display:block;
z-index:1;
}
#btn-nav:hover {
cursor:pointer;
}
#btn-nav span:nth-child(2) {
top:10px;
}
#btn-nav span:nth-child(3) {
top:20px;
}
#btn-nav span {
height: 4px;
width: 30px;
background: white;
content: "";
text-indent: -999em;
display:inline-block;
position:absolute;
zoom: 1;
top:0px;
left:0px;
text-align:center;
-webkit-transition: top .3s cubic-bezier(0.165,.84,.44,1);
-webkit-transform: rotate(0deg);
}
#btn-nav:hover > span, #btn-nav.open > span {
top:10px;
}
#btn-nav.open > span:nth-child(1) {
-webkit-animation: rotateAni .2s .1s forwards, expandAni .3s .3s forwards;
}
#btn-nav.open > span:nth-child(2) {
-webkit-animation: rotateAni .2s .1s forwards, expandAni-2 .3s .3s forwards;
}
#btn-nav.open > span:nth-child(3) {
-webkit-animation: rotateAni .2s .1s forwards, expandAni-3 .3s .3s forwards;
}
#-webkit-keyframes rotateAni {
0% {-webkit-transform: rotate(0deg);}
100% {-webkit-transform: rotate(90deg);}
}
#-webkit-keyframes expandAni {
0% {left:0;}
100% {left:-10px;}
}
#-webkit-keyframes expandAni-2 {
0% {left:0;}
100% {left:0px;}
}
#-webkit-keyframes expandAni-3 {
0% {left:0;}
100% {left:10px;}
}
#main-nav {
position:fixed;
left:0;
top:0;
display:block;
width:100%;
height:100%;
z-index:-1;
}
.slice {
width:25%;
height:30%;
min-height:30%;
float:left;
background:black;
opacity:0;
-webkit-transition: 1s;
}
.background {
position:absolute;
left:0;
top:0;
width:100%;
height:100%;
z-index:-1;
}

Managed to do it; deleted the layout and started again.
The main thing was to set overflow hidden on the master div and give it a min-height.
Followed the answers here: Expanding a parent <div> to the height of its children
#master {
background: #000;
height: auto;
min-height: 100%;
overflow: hidden;
position: relative;
width: 100%;
}
#main-nav {
left: 0;
position: absolute;
top: 0;
display: block;
height: 100%;
position: fixed;
width: 100%;
z-index: -1;
}
.slice {
background: #000;
float: left;
height: 33.66%;
opacity: 0;
filter: alpha(opacity=0);
width: 25%;
-webkit-transition: 1s;
}

Related

How to change the position of a button?

I have a question. I wanted to use a button from codepen.io on my website (this one: https://codepen.io/emared/pen/RYgbaJ/). Everything works with the button but it appears on the end of my website. I want it to be just below my text. Here's my code:
<h3 style="padding-top: 35;">
Text</h3>
<div id="wrapper">
<a href="#" class="my-super-cool-btn">
<div class="dots-container">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
</div>
<span>Go!</span>
</a>
</div>
And in my CSS-Document I just pasted everything from the codepen page.
Now this is what it looks like: https://ibb.co/G3cmGdQ
Why's there that huge space between "Text" and the button?
Thanks for your help! 🙏
Look at the following code:
#import url('https://fonts.googleapis.com/css?family=Montserrat:900');
body{
margin:0;
padding:0;
background-color:#292929;
font-family: 'Montserrat', sans-serif;
}
.heading {
text-align: center;
margin-top: 50px;
color: #fff;
}
#wrapper{
margin-bottom: 30px;
width:100vw;
height:100vh;
box-sizing:border-box;
display:flex;
align-items:center;
justify-content:center;
}
.my-super-cool-btn{
position:relative;
text-decoration:none;
color:#fff;
letter-spacing:1px;
font-size:2rem;
box-sizing:border-box;
}
.my-super-cool-btn span{
position:relative;
box-sizing:border-box;
display:flex;
align-items:center;
justify-content:center;
width:200px;
height:200px;
}
.my-super-cool-btn span:before{
content:'';
width:100%;
height:100%;
display:block;
position:absolute;
border-radius:100%;
border:7px solid #F3CF14;
box-sizing:border-box;
transition: all .85s cubic-bezier(0.25, 1, 0.33, 1);
box-shadow: 0 30px 85px rgba(0,0,0,0.14), 0 15px 35px rgba(0,0,0,0.14);
}
.my-super-cool-btn:hover span:before{
transform:scale(0.8);
box-shadow: 0 20px 55px rgba(0,0,0,0.14), 0 15px 35px rgba(0,0,0,0.14);
}
.my-super-cool-btn .dots-container{
opacity:0;
animation: intro 1.6s;
animation-fill-mode: forwards;
}
.my-super-cool-btn .dot{
width:8px;
height:8px;
display:block;
background-color:#F3CF14;
border-radius:100%;
position:absolute;
transition: all .85s cubic-bezier(0.25, 1, 0.33, 1);
}
.my-super-cool-btn .dot:nth-child(1){
top:50px;
left:50px;
transform:rotate(-140deg);
animation: swag1-out 0.3s;
animation-fill-mode: forwards;
opacity:0;
}
.my-super-cool-btn .dot:nth-child(2){
top:50px;
right:50px;
transform:rotate(140deg);
animation: swag2-out 0.3s;
animation-fill-mode: forwards;
opacity:0;
}
.my-super-cool-btn .dot:nth-child(3){
bottom:50px;
left:50px;
transform:rotate(140deg);
animation: swag3-out 0.3s;
animation-fill-mode: forwards;
opacity:0;
}
.my-super-cool-btn .dot:nth-child(4){
bottom:50px;
right:50px;
transform:rotate(-140deg);
animation: swag4-out 0.3s;
animation-fill-mode: forwards;
opacity:0;
}
.my-super-cool-btn:hover .dot:nth-child(1){
animation: swag1 0.3s;
animation-fill-mode: forwards;
}
.my-super-cool-btn:hover .dot:nth-child(2){
animation: swag2 0.3s;
animation-fill-mode: forwards;
}
.my-super-cool-btn:hover .dot:nth-child(3){
animation: swag3 0.3s;
animation-fill-mode: forwards;
}
.my-super-cool-btn:hover .dot:nth-child(4){
animation: swag4 0.3s;
animation-fill-mode: forwards;
}
#keyframes intro {
0% {
opacity:0;
}
100% {
opacity:1;
}
}
#keyframes swag1 {
0% {
top:50px;
left:50px;
width:8px;
}
50% {
width:30px;
opacity:1;
}
100% {
top:20px;
left:20px;
width:8px;
opacity:1;
}
}
#keyframes swag1-out {
0% {
top:20px;
left:20px;
width:8px;
}
50% {
width:30px;
opacity:1;
}
100% {
top:50px;
left:50px;
width:8px;
opacity:0;
}
}
#keyframes swag2 {
0% {
top:50px;
right:50px;
width:8px;
}
50% {
width:30px;
opacity:1;
}
100% {
top:20px;
right:20px;
width:8px;
opacity:1;
}
}
#keyframes swag2-out {
0% {
top:20px;
right:20px;
width:8px;
}
50% {
width:30px;
opacity:1;
}
100% {
top:50px;
right:50px;
width:8px;
opacity:0;
}
}
#keyframes swag3 {
0% {
bottom:50px;
left:50px;
width:8px;
}
50% {
width:30px;
opacity:1;
}
100% {
bottom:20px;
left:20px;
width:8px;
opacity:1;
}
}
#keyframes swag3-out {
0% {
bottom:20px;
left:20px;
width:8px;
}
50% {
width:30px;
opacity:1;
}
100% {
bottom:50px;
left:50px;
width:8px;
opacity:0;
}
}
#keyframes swag4 {
0% {
bottom:50px;
right:50px;
width:8px;
}
50% {
width:30px;
opacity:1;
}
100% {
bottom:20px;
right:20px;
width:8px;
opacity:1;
}
}
#keyframes swag4-out {
0% {
bottom:20px;
right:20px;
width:8px;
}
50% {
width:30px;
opacity:1;
}
100% {
bottom:50px;
right:50px;
width:8px;
opacity:0;
}
}
<h3 class="heading">Text goes here</h3>
<div id="wrapper">
<a href="#" class="my-super-cool-btn">
<div class="dots-container">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
</div>
<span>Go!</span>
</a>
</div>
Please check the code below:
#import url("https://fonts.googleapis.com/css?family=Montserrat:900");
body {
margin: 0;
padding: 0;
background-color: #292929;
font-family: "Montserrat", sans-serif;
}
.title {
text-align: center;
color: #fff;
font-size: 50px;
padding-top: 35px;
margin: 0;
}
#wrapper {
margin-bottom: 30px;
width: 100vw;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
}
.my-super-cool-btn {
position: relative;
text-decoration: none;
color: #fff;
letter-spacing: 1px;
font-size: 2rem;
box-sizing: border-box;
}
.my-super-cool-btn span {
position: relative;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
width: 200px;
height: 200px;
}
.my-super-cool-btn span:before {
content: "";
width: 100%;
height: 100%;
display: block;
position: absolute;
border-radius: 100%;
border: 7px solid #f3cf14;
box-sizing: border-box;
transition: all 0.85s cubic-bezier(0.25, 1, 0.33, 1);
box-shadow: 0 30px 85px rgba(0, 0, 0, 0.14), 0 15px 35px rgba(0, 0, 0, 0.14);
}
.my-super-cool-btn:hover span:before {
transform: scale(0.8);
box-shadow: 0 20px 55px rgba(0, 0, 0, 0.14), 0 15px 35px rgba(0, 0, 0, 0.14);
}
.my-super-cool-btn .dots-container {
opacity: 0;
animation: intro 1.6s;
animation-fill-mode: forwards;
}
.my-super-cool-btn .dot {
width: 8px;
height: 8px;
display: block;
background-color: #f3cf14;
border-radius: 100%;
position: absolute;
transition: all 0.85s cubic-bezier(0.25, 1, 0.33, 1);
}
.my-super-cool-btn .dot:nth-child(1) {
top: 50px;
left: 50px;
transform: rotate(-140deg);
animation: swag1-out 0.3s;
animation-fill-mode: forwards;
opacity: 0;
}
.my-super-cool-btn .dot:nth-child(2) {
top: 50px;
right: 50px;
transform: rotate(140deg);
animation: swag2-out 0.3s;
animation-fill-mode: forwards;
opacity: 0;
}
.my-super-cool-btn .dot:nth-child(3) {
bottom: 50px;
left: 50px;
transform: rotate(140deg);
animation: swag3-out 0.3s;
animation-fill-mode: forwards;
opacity: 0;
}
.my-super-cool-btn .dot:nth-child(4) {
bottom: 50px;
right: 50px;
transform: rotate(-140deg);
animation: swag4-out 0.3s;
animation-fill-mode: forwards;
opacity: 0;
}
.my-super-cool-btn:hover .dot:nth-child(1) {
animation: swag1 0.3s;
animation-fill-mode: forwards;
}
.my-super-cool-btn:hover .dot:nth-child(2) {
animation: swag2 0.3s;
animation-fill-mode: forwards;
}
.my-super-cool-btn:hover .dot:nth-child(3) {
animation: swag3 0.3s;
animation-fill-mode: forwards;
}
.my-super-cool-btn:hover .dot:nth-child(4) {
animation: swag4 0.3s;
animation-fill-mode: forwards;
}
#keyframes intro {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#keyframes swag1 {
0% {
top: 50px;
left: 50px;
width: 8px;
}
50% {
width: 30px;
opacity: 1;
}
100% {
top: 20px;
left: 20px;
width: 8px;
opacity: 1;
}
}
#keyframes swag1-out {
0% {
top: 20px;
left: 20px;
width: 8px;
}
50% {
width: 30px;
opacity: 1;
}
100% {
top: 50px;
left: 50px;
width: 8px;
opacity: 0;
}
}
#keyframes swag2 {
0% {
top: 50px;
right: 50px;
width: 8px;
}
50% {
width: 30px;
opacity: 1;
}
100% {
top: 20px;
right: 20px;
width: 8px;
opacity: 1;
}
}
#keyframes swag2-out {
0% {
top: 20px;
right: 20px;
width: 8px;
}
50% {
width: 30px;
opacity: 1;
}
100% {
top: 50px;
right: 50px;
width: 8px;
opacity: 0;
}
}
#keyframes swag3 {
0% {
bottom: 50px;
left: 50px;
width: 8px;
}
50% {
width: 30px;
opacity: 1;
}
100% {
bottom: 20px;
left: 20px;
width: 8px;
opacity: 1;
}
}
#keyframes swag3-out {
0% {
bottom: 20px;
left: 20px;
width: 8px;
}
50% {
width: 30px;
opacity: 1;
}
100% {
bottom: 50px;
left: 50px;
width: 8px;
opacity: 0;
}
}
#keyframes swag4 {
0% {
bottom: 50px;
right: 50px;
width: 8px;
}
50% {
width: 30px;
opacity: 1;
}
100% {
bottom: 20px;
right: 20px;
width: 8px;
opacity: 1;
}
}
#keyframes swag4-out {
0% {
bottom: 20px;
right: 20px;
width: 8px;
}
50% {
width: 30px;
opacity: 1;
}
100% {
bottom: 50px;
right: 50px;
width: 8px;
opacity: 0;
}
}
<h3 class="title">Text</h3>
<div id="wrapper">
<a href="#" class="my-super-cool-btn">
<div class="dots-container">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
</div>
<span>Go!</span>
</a>
</div>

I'm attempting to put my logo animation in the center of the page, but the positioning gets all messed up

Originally, just for the logo alone, I used fixed positioning since the divs for each square would not be in the right place otherwise. With a fixed position, they won't go into my inner div box though. The inner and outer div boxes have colour just so I can see them at the moment. Does anyone know of a way to make the position for my divs relative whiel still keeping them in the right position for the animation so they cross over and are symmetrical?
<!DOCTYPE html>
<html>
<head>
<style>
div.outer {
top: 0%;
left: 0%;
margin: 0 auto;
width: 100%;
height: 100%;
position: fixed;
background-color: red;
opacity: 0.5;
}
div.inner {
width: 60%;
height: 60%;
top: 25%;
margin: 0 auto;
position: relative;
background:orange;
}
body {
display: block;
height: 100%;
}
div.a {
width: 200px;
height: 200px;
background-color: blue;
position: relative;
animation-name: raveA;
animation-duration: 2.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}
div.b {
width: 200px;
height: 200px;
background-color: red;
position: relative;
animation-name: raveB;
animation-duration: 2.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}
div.c {
width: 200px;
height: 200px;
background-color: green;
position: relative;
animation-name: raveC;
animation-duration: 2.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}
div.d {
width: 200px;
height: 200px;
background-color: yellow;
position: relative;
animation-name: raveD;
animation-duration: 2.5s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}
#keyframes raveA {
0% {background-color:blue; left:0px; top:0px;}
50% {background-color:red; left:230px; top:230px;}
100% {background-color:rgb(240,101,43); left:55px; top:20px; transform:skewX(-10deg);}
}
#keyframes raveB {
0% {background-color:red; left:250px; top:250px;}
50% {background-color:yellow; left:20px; top:20px;}
100% {background-color:rgb(247,189,0); left:230px; top:230px; transform:skewX(-10deg);}
}
#keyframes raveC {
0% {background-color:green; left:0px; top:250px;}
50% {background-color:blue; left:230px; top:20px;}
100% {background-color:rgb(0,174,233); left:20px; top:230px; transform:skewX(-10deg);}
}
#keyframes raveD {
0% {background-color:yellow; left:250px; top:0px;}
50% {background-color:green; left:20px; top:230px;}
100% {background-color:rgb(140,189,0); left:265px; top:20px; transform:skewX(-10deg);}
}
</style>
</head>
<body>
<div class="outer">
<div class="inner">
<div class="a"></div>
<div class="b"></div>
<div class="c"></div>
<div class="d"></div>
</div>
</div>
</body>
</html>

CSS3: Center Text (content) in div:before

I wrote some code to create a layover with some text. Now I have two problems:
1) I want to center the text.
2) I want to make the layover to be a link.
As I am a CSS newbie, I hope you can give me any advice!
Best regards!
.hover_div {
position:relative;
width:200px;
height:200px;
}
.hover_div img {
width:100%;
vertical-align:top;
}
.hover_div:after {
content: "";
position: absolute;
width:100%; height: 100%;
top: 0; left: 0;
background:rgba(0,0,0,0.6);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.hover_div:before {
content: attr(data-content);
color:#fff;
position:absolute;
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
z-index: 1;
}
.hover_div:hover:after {
opacity:1;
}
.hover_div:hover:before {
opacity:1;
}
<div data-content="Elektro" class="hover_div">
<img src="http://i.stack.imgur.com/Sjsbh.jpg" alt="" />
</div>
I've updated your code in the following JSFiddle: https://jsfiddle.net/rvxo7fn5/
I've added the following lines to the :before:
text-align:center;
width: 100%;
margin-top:50%;
transform: translateY(-50%);
Basically, text-align: center; of course centers the text horizontally. However, an absolute positioned div has no width, which is why I added the width: 100%. Next you need to center it vertically. The margin-top: 50%; moves the div 50% of the height of the parent div. transform: translateY(-50%) moves the div back 50% of the height of the div itself. This aligns it in the center of the parent. (50% of parent height - 50% height of child div).
You also mentioned wanting it to be a link. This can be achieved by simply replacing the <div> with a <a> and adding display: block; to your .hover_div class. This gives it the properties a div would also have.
Hope that helps!
Update the :hover style as below.
.hover_div:hover:before
{
opacity:1;
width:100%;
text-align:center;
text-decoration:underline;
cursor:pointer;
}
You can make it link by replacing <div> with <a>.
.hover_div {
position:relative;
display: block;
width:200px;
height:200px;
}
.hover_div img {
width:100%;
vertical-align:top;
}
.hover_div:after {
content: "";
position: absolute;
width:100%; height: 100%;
top: 0; left: 0;
background:rgba(0,0,0,0.6);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.hover_div:before {
content: attr(data-content);
color:#fff;
position:absolute;
text-align: center;
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
transform: translateY(-50%);
z-index: 1;
width: 100%;
left: 0;
top: 50%;
}
.hover_div:hover:after {
opacity:1;
}
.hover_div:hover:before {
opacity:1;
}
<a href="#" data-content="Elektro" class="hover_div">
<img src="http://i.stack.imgur.com/Sjsbh.jpg" alt="" />
</a>
The text can be centered by adding left: 50%; top: 50%; transform: translate(-50%, -50%).
Pseudo elements like :after and :before cannot be accessed from the DOM. So a link can't be made out of it.
.hover_div {
position: relative;
width: 200px;
height: 200px;
}
.hover_div img {
width: 100%;
vertical-align: top;
}
.hover_div:after {
content: "";
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.6);
opacity: 0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.hover_div:before {
content: attr(data-content);
color: #fff;
position: absolute;
opacity: 0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
z-index: 1;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.hover_div:hover:after {
opacity: 1;
}
.hover_div:hover:before {
opacity: 1;
}
<div data-content="Elektro" class="hover_div">
<img src="http://i.stack.imgur.com/Sjsbh.jpg" alt="" />
</div>
.hover_div {
position:relative;
width:200px;
height:200px;
}
.hover_div img {
width:100%;
vertical-align:top;
}
.hover_div:after {
content: "";
position: absolute;
width:100%; height: 100%;
top: 0; left: 0;
background:rgba(0,0,0,0.6);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.hover_div:before {
content: attr(data-content);
color:#fff;
position:absolute;
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
z-index: 1;
text-align:center;
height:100%;
width:100%;
padding-top:50%;
}
.hover_div:hover:after {
opacity:1;
}
.hover_div:hover:before {
opacity:1;
}
<div data-content="Elektro" class="hover_div">
<img src="http://i.stack.imgur.com/Sjsbh.jpg" alt="" />
</div>

Trying to add preloader with only HTML/CSS

I'm very humbled by this right now. I'm trying to add this Skype styled preloader into this theme I'm making, but I have no idea how to call the function. I feel as if it needs Javascript, but it's not on the site. Please & Thank you for future reference
<!-- HTML FILES -->
<div class="table">
<div class="table--cell">
<div class="loader">
<span class="loader--ball loader--ball__first"></span>
<span class="loader--ball"></span>
<span class="loader--ball"></span>
<span class="loader--ball"></span>
</div>
</div>
</div>
<!-- CSS FILE -->
html body{
background-color:#2980b9;
width:100%;
height:100vh;
}
.table{
width:100%;
height:100%;
display:table;
.table--cell{
display:table-cell;
vertical-align:middle;
text-align:center;
}
}
.loader{
display:inline-block;
width:120px;
height:120px;
.loader--ball{
position:absolute;
left:0;
right:0;
margin:0 auto;
width:10px;
height:10px;
border-radius:50%;
background:#ecf0f1;
transform-origin:0 60px;
display:block;
animation: 2s rotate cubic-bezier(0.775, 0.030, 0.350, 1.000) infinite;
#for $i from 1 through 4 {
&:nth-child(#{$i}) {
animation-delay:(0.1s * $i);
}
}
}
}
#keyframes rotate {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loader--ball:first-child{
background:none;
}
.loader--ball__first:before{
content:'';
width:10px;
height:10px;
position:absolute;
z-index:10;
top:0;
bottom:0;
background:#ecf0f1;
display:block;
border-radius:50%;
animation:2s grow cubic-bezier(0.775, 0.035, 0.310, 1.000) infinite;
}
#keyframes grow {
0%,
10% {
width:20px;
height:20px;
top:-2px;
left:-5px;
}
50% {
width:10px;
height:10px;
left:-5px;
}
85%, 100% {
width:20px;
height:20px;
top:-2px;
left:-5px;
}
}
The example is using SASS (scss). You need the compiled css if you are not using Sass. Example with compiled CSS
Compiled CSS:
html body {
background-color: #2980b9;
width: 100%;
height: 100vh;
}
.table {
width: 100%;
height: 100%;
display: table;
}
.table .table--cell {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.loader {
display: inline-block;
width: 120px;
height: 120px;
}
.loader .loader--ball {
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
width: 10px;
height: 10px;
border-radius: 50%;
background: #ecf0f1;
-webkit-transform-origin: 0 60px;
-ms-transform-origin: 0 60px;
transform-origin: 0 60px;
display: block;
-webkit-animation: 2s rotate cubic-bezier(0.775, 0.03, 0.35, 1) infinite;
animation: 2s rotate cubic-bezier(0.775, 0.03, 0.35, 1) infinite;
}
.loader .loader--ball:nth-child(1) {
-webkit-animation-delay: 0.1s;
animation-delay: 0.1s;
}
.loader .loader--ball:nth-child(2) {
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s;
}
.loader .loader--ball:nth-child(3) {
-webkit-animation-delay: 0.3s;
animation-delay: 0.3s;
}
.loader .loader--ball:nth-child(4) {
-webkit-animation-delay: 0.4s;
animation-delay: 0.4s;
}
#-webkit-keyframes rotate {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#keyframes rotate {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.loader--ball:first-child {
background: none;
}
.loader--ball__first:before {
content: '';
width: 10px;
height: 10px;
position: absolute;
z-index: 10;
top: 0;
bottom: 0;
background: #ecf0f1;
display: block;
border-radius: 50%;
-webkit-animation: 2s grow cubic-bezier(0.775, 0.035, 0.31, 1) infinite;
animation: 2s grow cubic-bezier(0.775, 0.035, 0.31, 1) infinite;
}
#-webkit-keyframes grow {
0%,
10% {
width: 20px;
height: 20px;
top: -2px;
left: -5px;
}
50% {
width: 10px;
height: 10px;
left: -5px;
}
85%, 100% {
width: 20px;
height: 20px;
top: -2px;
left: -5px;
}
}
#keyframes grow {
0%,
10% {
width: 20px;
height: 20px;
top: -2px;
left: -5px;
}
50% {
width: 10px;
height: 10px;
left: -5px;
}
85%, 100% {
width: 20px;
height: 20px;
top: -2px;
left: -5px;
}
}

Hover css slide out for multiple objects/items

I am doing a website project and I would like to have this cool hover effect but I can't seem to get it to work right?
I have a vinyl record case image that slides to the left with a title (overflow:hidden) to reveal the record image behind it. At the same time from the left I want a description of the record to slid out from behind the vinly record case thats moving to the left and be on top of the record image with a little opacity so you can still see the record(this part is easy)
Here is the html code:
<div id="stations">
<div class="grid_3">
<div class="records"><!-- sleeve -->
<h3>Groove Salad</h3>
<div class="recordsinfo">Station description.</div>
</div>
</div>
</div>
and here is the css code:
#stations>div {
background-image: url(http://benlevywebdesign.com/somafm/images/SomaFMrecord.png);
background-repeat:no-repeat;
height: 220px;
margin-bottom: 20px;
position: relative;
overflow:hidden;
}
#stations>div>.records{
background-image: url(http://benlevywebdesign.com/somafm/images/SomaFM.png);
background-repeat:no-repeat;
height: 220px;
margin-bottom: 20px;
overflow:hidden;
position:relative;
}
#stations>div>.records>h3 {
color: #FFF;
background-color: rgba(255,255,255, 0.45);
width:200px;
margin-top:0px;
margin-bottom:-5px;
padding: 10px 10px 3px;
}
#stations>div>.records>.recordsinfo{
position: absolute;
left:-150px;
bottom: 0;
margin: 5px 10px;
}
#-moz-keyframes slideout {
0% { left:0; }
100% { left:-100px; }
}
#-webkit-keyframes slideout {
0% { left:0; }
100% { left:-100px; }
}
#keyframes slideout {
0% { left:0; }
100% { left:-100px; }
}
#stations>div>.records:hover{
height: 220px;
width:220%;
margin-bottom: 20px;
left:-100px;
overflow:hidden;
position: relative;
-moz-animation: slideout 0.75s 1;
-webkit-animation: slideout 0.75s 1;
animation: slideout 0.75s 1;
}
#stations>div>.records>.recordsinfo:hover{
height: 220px;
width:220%;
left:150px;
overflow:hidden;
position: relative;
-moz-animation: slidein 0.75s 1;
-webkit-animation: slidein 0.75s 1;
animation: slidein 0.75s 1;
}
and here is a fiddle of it working up until the last part which is the description not working and sliding out left!
Updated fiddle
http://jsfiddle.net/Xc9U6/11/
Try this - DEMO
HTML
<div id="stations">
<div class="grid_3">
<div class="records"><!-- sleeve -->
<h3>Groove Salad</h3>
</div>
<div class="recordsinfo">Station description.</div>
</div>
</div>
CSS
#stations > div {
background-image: url(http://benlevywebdesign.com/somafm/images/SomaFMrecord.png);
background-repeat:no-repeat;
height: 220px;
margin-bottom: 20px;
position: relative;
overflow:hidden;
}
#stations > div:hover .records {
margin-left: -110px;
}
#stations .records{
background-image: url(http://benlevywebdesign.com/somafm/images/SomaFM.png);
background-repeat:no-repeat;
height: 220px;
margin: 0 0 20px 0;
overflow:hidden;
position:relative;
-webkit-transition: all .75s;
-moz-transition: all .75s;
transition: all .75s;
}
#stations h3 {
color: #FFF;
background-color: rgba(255,255,255, 0.45);
width:200px;
margin-top:0px;
margin-bottom:-5px;
padding: 10px 10px 3px;
}
#stations > div:hover .recordsinfo {
margin-left: 0;
}
#stations .recordsinfo {
background: rgba(0, 0, 0, .8);
color: #fff;
position: absolute;
width: 150px;
bottom: 0;
margin: 5px 10px 5px -150px;
-webkit-transition: all .75s;
-moz-transition: all .75s;
transition: all .75s;
}
If I understood well you want the title to remain where it is? if so here you go:
#stations > div > .records:hover h3 {
margin-left: 100px;
}
Finally! You had lots of different issues here, from setting a width of 220%, instead of px, To trying to animate a child of an animation (so it's positions were off), to not defining the slidein animation you wanted to use.
Try this: jsFiddle