How to control speed and animation of a breathing button using css - html

I have a breathing button and 2 left and right arrow having animation from left to right and right to left. I need to sync the animation speed of both the left and right arrow with the breathing button.When button will expand need to move both right and left arrow forward towards button and vice versa. Here is the code below
html
<div class="floatleft arrow arrow-right animate-right-to-left">Message2</div>
<button id="breathing-button" class="floatleft">Breathing Button</button>
<div class="floatleft arrow arrow-left animate-left-to-right">Message1</div>
css
#breathing-button {
width: 270px;
padding: 20px;
border: 1px solid #d1d1d1;
animation: breathing 1s ease-out infinite normal;
font-size: 24px;
background: #5885cb;
color: #fff;
-webkit-font-smoothing: antialiased;
border-radius: 8px;
text-align: center;
}
#keyframes breathing {
0% {
-webkit-transform: scale(0.9);
-ms-transform: scale(0.9);
transform: scale(0.9);
}
25% {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
60% {
-webkit-transform: scale(0.9);
-ms-transform: scale(0.9);
transform: scale(0.9);
}
100% {
-webkit-transform: scale(0.9);
-ms-transform: scale(0.9);
transform: scale(0.9);
}
}
.arrow {
position: relative;
font-size: 13px;
max-width: 100px;
background: #D94F1A;
height: 40px;
line-height: 40px;
text-align: center;
color: white;
visibility: hidden;
opacity: 0;
transition: visibility 0s, opacity 0.3s ease-in-out;
top: 15px;
}
.arrow {
visibility: visible;
opacity: 1;
}
.arrow.animate-left-to-right {
animation-name: move-left-to-right;
animation-duration: 1s;
animation-delay: 0.6s;
animation-iteration-count: infinite;
animation-direction: alternative;
}
.arrow.animate-right-to-left {
animation-name: move-right-to-left;
animation-duration: 1s;
animation-delay: 0.6s;
animation-iteration-count: infinite;
animation-direction: alternative;
}
#keyframes move-left-to-right {
0% {
transform: translateX(5%);
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.2);
}
50% {
transform: translateX(15%);
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.4);
}
100% {
transform: translateX(5%);
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.2);
}
}
#keyframes move-right-to-left {
0% {
transform: translateX(-5%);
box-shadow: -3px 5px 5px rgba(0, 0, 0, 0.2);
}
50% {
transform: translateX(-15%);
box-shadow: -3px 5px 5px rgba(0, 0, 0, 0.4);
}
100% {
transform: translateX(-5%);
box-shadow: -3px 5px 5px rgba(0, 0, 0, 0.2);
}
}
.arrow-right:after {
content: "";
position: absolute;
right: -20px;
top: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 20px solid #D94F1A;
}
/*left arrow*/
.arrow-left {
border-radius: 0 5px 5px 0;
}
.arrow-left:before {
content: "";
position: absolute;
left: -20px;
top: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-right: 20px solid #D94F1A;
}
.floatleft{
float:left;
width:100px;
margin-left:10px;
margin-right:10px;
}

Changed breathing keyframes to this
#keyframes breathing {
0% {
-webkit-transform: scale(0.9);
-ms-transform: scale(0.9);
transform: scale(0.9);
}
50% {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
100% {
-webkit-transform: scale(0.9);
-ms-transform: scale(0.9);
transform: scale(0.9);
}
}
Demo

Cleaned your code a little.
#breathing-button {
width: 270px;
padding: 20px;
border: 1px solid #d1d1d1;
animation: breathing 1s infinite forwards;
font-size: 24px;
background: #5885cb;
color: #fff;
-webkit-font-smoothing: antialiased;
border-radius: 8px;
text-align: center;
}
#keyframes breathing {
0% {
-webkit-transform: scale(0.9);
-ms-transform: scale(0.9);
transform: scale(0.9);
}
50% {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
100% {
-webkit-transform: scale(0.9);
-ms-transform: scale(0.9);
transform: scale(0.9);
}
}
.arrow {
position: relative;
font-size: 13px;
max-width: 100px;
background: #D94F1A;
height: 40px;
line-height: 40px;
text-align: center;
color: white;
top: 15px;
}
.arrow.animate-left-to-right {
animation: move-left-to-right 1s infinite forwards;
}
.arrow.animate-right-to-left {
animation: move-right-to-left 1s infinite forwards;
}
#keyframes move-left-to-right {
0% {
transform: translateX(15%);
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.4);
}
50% {
transform: translateX(5%);
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.2);
}
100% {
transform: translateX(15%);
box-shadow: 3px 5px 5px rgba(0, 0, 0, 0.4);
}
}
#keyframes move-right-to-left {
0% {
transform: translateX(-15%);
box-shadow: -3px 5px 5px rgba(0, 0, 0, 0.4);
}
50% {
transform: translateX(-5%);
box-shadow: -3px 5px 5px rgba(0, 0, 0, 0.2);
}
100% {
transform: translateX(-15%);
box-shadow: -3px 5px 5px rgba(0, 0, 0, 0.4);
}
}
.arrow-right {
border-radius: 5px 0 0 5px;
}
.arrow-left {
border-radius: 0 5px 5px 0;
}
.arrow-right:after, .arrow-left:before {
content: "";
position: absolute;
top: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.arrow-right:after {
right: -20px;
border-left: 20px solid #D94F1A;
}
.arrow-left:before {
left: -20px;
border-right: 20px solid #D94F1A;
}
.floatleft {
float: left;
width: 100px;
margin-left: 10px;
margin-right: 10px;
}

Related

On hover change animation with transition

I need to change the animation with a transition effect. That is change first transition to another with a flow. When I tried for the same the animation changes with a fast change as in below snippet. Is there any way to animate the change in animation. I have tried the below code.
body{
background: url('https://i.pinimg.com/originals/0b/76/08/0b760848c89b9e4abd03f74f19419498.jpg');
}
.bubble{
top: 50px;
left: 80px;
height: 100px;
width: 100px;
color: #000;
box-sizing: border-box;
border-radius: 50%;
box-shadow: 0 5px 15px 0px rgba(0,0,0,0.4);
transform: translatey(0px);
cursor: pointer;
position: absolute;
border: 10px solid rgba(255,255,255,0.2);
animation: float 4s ease-in-out infinite;
}
.bubble span {
font-size: 12px;
line-height: 85px;
position: absolute;
bottom: 0;
top: 0;
right: 0;
left: 0;
text-align: center;
border-radius: 50%;
background: red;
}
.bubble:before {
position: absolute;
content: "";
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
border-radius: 50%;
box-shadow: 0 0 rgba(255, 255, 255, 0.1), 0 0 0 8px rgba(255, 255, 255, 0.1),
0 0 0 16px rgba(255, 255, 255, 0.1), 0 0 0 24px rgba(255, 255, 255, 0.1);
z-index: -1;
animation: ripples 1s linear infinite;
animation-play-state: paused;
opacity: 0;
visibility: hidden;
transition: 0.5s;
transform: scale(0.5);
}
.bubble:hover {
transition: all 2s;
animation: tofixed 4s forwards;
box-shadow: none;
border-color: transparent;
}
.bubble:hover:before {
animation-play-state: running;
opacity: 1;
visibility: visible;
transform: scale(1);
}
#keyframes float {
0% { box-shadow: 0 5px 15px 0px rgba(0,0,0,0.6); transform: translatey(0px) scale(0.9); }
50% { box-shadow: 0 25px 15px 0px rgba(0,0,0,0.2); transform: translatey(-20px) scale(1); }
100% { box-shadow: 0 5px 15px 0px rgba(0,0,0,0.6); transform: translatey(0px) scale(0.9); }
}
#keyframes tofixed {
to { transform: translatey(0px) scale(0.9); }
}
#keyframes ripples {
to {
box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.1), 0 0 0 16px rgba(255, 255, 255, 0.1),
0 0 0 24px rgba(255, 255, 255, 0.1), 0 0 0 32px rgba(255, 255, 255, 0);
}
}
<div class="bubble">
<span class="bgviolet">ODOSTORE</span>
</div>
In the above snippet you can see the change in animation is instantly when I hover on it.

centering div fixed position -no solution worked

I just want to make a preloader that's positioned in the middle of the page.
Requirements:
position: fixed;
centered on the X-axis
It's just a div with class 'preloader' in body. Body is this div's direct parent, no other wrapper in between.
.preloader {
position: fixed;
display: inline-block;
z-index: 99;
top: 45%;
left: 50%;
width: 60px;
height: 60px;
-ms-transform: translateX(100px); /*100px just to test if it moved at all, initially had -50%, see list below*/
-webkit-transform: translateX(100px);
transform: translateX(100px);
//=====rest is just animation and aesthetics======
border: 3px solid #8A2EE6;
border-radius: 50%;
border-bottom: 3px solid black;
box-shadow: 0px 0px 20px 1px rgba(153, 102, 255, 0.5) inset, 0px 0px 20px 1px rgba(153, 102, 255, 0.5);
animation-name: rotatePreloader;
animation-duration: 0.65s;
animation-direction: normal;
animation-iteration-count: infinite;
animation-timing-function: linear;
transition: opacity 1s;
}
I've done:
display: block;
display: inline-block;
translateX(-50%);
translateX(30px);
translate(-50%, 0);
translate(30px, 0);
translate(-50%, -50%);
rearranging the transforms.. lol
took off -o & -mos
margin: 0 auto (worked with position: relative when I didn't need it to be fixed)
https://jsfiddle.net/goa3v2ke/#
You need to do like this, where you set top/left to 50% and then move them back with translate using the same value, int this case -50%.
Sample 1 now center it both horizontal and vertical, and by change the top/left values, you can move it in the direction you want, sample 2 has 33% as top value.
Update based on question edit
The small X/Y-axis offset is caused by the rotate being executed before the translate, so change your #keyframes rule to this, showed in sample 3 and an update of your fiddle
#keyframes rotatePreloader {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
}
}
Sample 1
.preloader {
position: fixed;
display: inline-block;
z-index: 99;
top: 50%;
left: 50%;
width: 60px;
height: 60px;
transform: translate(-50%,-50%);
/*=====rest is just animation and aesthetics======*/
border: 3px solid #8A2EE6;
border-radius: 50%;
border-bottom: 3px solid black;
box-shadow: 0px 0px 20px 1px rgba(153, 102, 255, 0.5) inset, 0px 0px 20px 1px rgba(153, 102, 255, 0.5);
animation-name: rotatePreloader;
animation-duration: 0.65s;
animation-direction: normal;
animation-iteration-count: infinite;
animation-timing-function: linear;
transition: opacity 1s;
}
<div class="preloader"></div>
Sample 2
.preloader {
position: fixed;
display: inline-block;
z-index: 99;
top: 33%;
left: 50%;
width: 60px;
height: 60px;
transform: translate(-50%,-50%);
/*=====rest is just animation and aesthetics======*/
border: 3px solid #8A2EE6;
border-radius: 50%;
border-bottom: 3px solid black;
box-shadow: 0px 0px 20px 1px rgba(153, 102, 255, 0.5) inset, 0px 0px 20px 1px rgba(153, 102, 255, 0.5);
animation-name: rotatePreloader;
animation-duration: 0.65s;
animation-direction: normal;
animation-iteration-count: infinite;
animation-timing-function: linear;
transition: opacity 1s;
}
<div class="preloader"></div>
Sample 3
.leftPreloaderBG {
position: fixed;
background-color: black;
width: 50%;
height: 100%;
z-index: 98;
top: 0px;
left: 0px;
transition: width 1s;
}
.leftPreloaderBG.loaded {
width: 0;
}
.rightPreloaderBG {
position: fixed;
background-color: black;
width: 50%;
height: 100%;
z-index: 98;
top: 0px;
right: 0px;
transition: width 1s;
}
.rightPreloaderBG.loaded {
width: 0;
}
#keyframes rotatePreloader {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
}
}
.preloader {
position: fixed;
display: inline-block;
z-index: 99;
top: 33%;
left: 50%;
width: 60px;
height: 60px;
transform: translate(-50%, -50%);
/*=====rest is just animation and aesthetics======*/
border: 3px solid #8A2EE6;
border-radius: 50%;
border-bottom: 3px solid black;
box-shadow: 0px 0px 20px 1px rgba(153, 102, 255, 0.5) inset, 0px 0px 20px 1px rgba(153, 102, 255, 0.5);
animation-name: rotatePreloader;
animation-duration: 0.65s;
animation-direction: normal;
animation-iteration-count: infinite;
animation-timing-function: linear;
transition: opacity 1s;
}
.preloader.loaded {
opacity: 0;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
width: 100%;
color: white;
font-size: 1em;
background-color: gray;
background-position: center;
background-repeat: repeat;
}
<body>
<div class="preloader"></div>
<div class="leftPreloaderBG"></div>
<div class="rightPreloaderBG"></div>
</body>
It is because you override the transform translate value in the keyframe animation. Try it like this:
.leftPreloaderBG {
position: fixed;
background-color: black;
width: 50%;
height: 100%;
z-index: 98;
top: 0px;
left: 0px;
transition: width 1s;
}
.leftPreloaderBG.loaded {
width: 0;
}
.rightPreloaderBG {
position: fixed;
background-color: black;
width: 50%;
height: 100%;
z-index: 98;
top: 0px;
right: 0px;
transition: width 1s;
}
.rightPreloaderBG.loaded {
width: 0;
}
#keyframes rotatePreloader {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
}
}
.preloader {
position: fixed;
display: inline-block;
z-index: 99;
top: 33%;
left: 50%;
width: 60px;
height: 60px;
transform: translate(-50%, -50%);
/*=====rest is just animation and aesthetics======*/
border: 3px solid #8A2EE6;
border-radius: 50%;
border-bottom: 3px solid black;
box-shadow: 0px 0px 20px 1px rgba(153, 102, 255, 0.5) inset, 0px 0px 20px 1px rgba(153, 102, 255, 0.5);
animation-name: rotatePreloader;
animation-duration: 0.65s;
animation-direction: normal;
animation-iteration-count: infinite;
animation-timing-function: linear;
transition: opacity 1s;
}
.preloader.loaded {
opacity: 0;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
width: 100%;
color: white;
font-size: 1em;
background-color: gray;
background-position: center;
background-repeat: repeat;
}
<body>
<div class="preloader"></div>
<div class="leftPreloaderBG"></div>
<div class="rightPreloaderBG"></div>
</body>

Hero image div overlay moves on resize

I've placed a profile picture div over my hero image. As i resize the window the profile pic moves. I've tried fixed, relative, absolute...nothing works. Any Ideas - thanks, adolfo - site: http://adolfobarreto.atwebpages.com/
html:
<div id="heroimage">
<div class="pulse1"></div>
<div class="pulse2"></div>
<div class="profilepicture"></div>
<div class="module mid">
<h2> Adolfo Barreto </h2>
<h4> Web Designer </h4>
</div>
</div>
css:
// Hero
html, body, #heroimage{
width:100%;
height:80%;
}
#heroimage{
background:url('/../assets/img/heroVector.jpg') center center;
background-size:cover;
}
#import url(http://fonts.googleapis.com/css?family=Roboto:400,900);
.mid h2 {
background-color: #7A3E48;
font-family: 'Roboto', sans-serif;
font-weight: 900;
color: white;
margin: 0;
position: absolute;
top: 40%;
left: 50.5%;
font-size: 2rem;
transform: translate(-50%, -50%);
}
.mid h4 {
background-color: #7A3E48;
font-family: 'Roboto', sans-serif;
font-weight: 900;
color: white;
margin: 0;
position: absolute;
top: 44%;
left: 50.5%;
font-size: 1.5rem;
transform: translate(-50%, -50%);
}
//end hero
// profile picture
.profilepicture {
position: absolute;
width: 180px;
height: 180px;
margin: 0px;
margin-top: 10%;
margin-left: 44.6%;
background: url(/../assets/img/AdolfoBarreto.4.jpg) no-repeat;
background-size: 180px 180px;
top: 0; left: 0; bottom: 0; right: 0;
z-index: 3;
-webkit-box-shadow:
0 0 0 10px rgba(255,255,255,.2),
0 0 5px 2px rgba(0,0,0,.3),
inset 0 0 0 10px rgba(0,0,255,.2);
-moz-box-shadow:
0 0 0 10px rgba(255,255,255,.2),
0 0 5px 2px rgba(0,0,0,.3),
inset 0 0 0 10px rgba(0,0,255,.2);
box-shadow:
0 0 0 10px rgba(255,255,255,.2),
0 0 5px 2px rgba(0,0,0,.3),
inset 0 0 0 10px rgba(0,0,255,.2);
-webkit-border-radius: 999px;
-moz-border-radius: 999px;
border-radius: 999px;
/* border-radius: 50% has issues on some mobile browsers */
}
.pulse1 {
position: absolute;
width: 200px;
height: 200px;
margin-top: 9.5%;
margin-left: 44%;
top: 0; left: 0; bottom: 0; right: 0;
z-index: 1;
opacity: 0;
border: 3px solid rgba(255,255,255,.1);
-webkit-animation: pulsejg1 4s linear infinite;
-moz-animation: pulsejg1 4s linear infinite;
animation: pulsejg1 4s linear infinite;
-webkit-border-radius: 999px;
-moz-border-radius: 999px;
border-radius: 999px;
-webkit-box-shadow: inset 0px 0px 15px 10px rgba(0, 0, 0, .6);
-moz-box-shadow: inset 0px 0px 15px 10px rgba(0, 0, 0, .6);
box-shadow: inset 0px 0px 15px 10px rgba(0, 0, 0, .6);
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.pulse2 {
position: absolute;
width: 200px;
height: 200px;
margin-top: 9.5%;
margin-left: 44%;
top: 0; left: 0; bottom: 0; right: 0;
z-index: 2;
opacity: 0;
border: 1px solid rgba(255,255,255,0);
-webkit-animation: pulsejg2 4s linear infinite;
-moz-animation: pulsejg2 4s linear infinite;
animation: pulsejg2 4s linear infinite;
-webkit-border-radius: 999px;
-moz-border-radius: 999px;
border-radius: 999px;
-webkit-box-shadow: inset 0px 0px 12px 5px rgba(255, 255, 255, .8);
-moz-box-shadow: inset 0px 0px 12px 5px rgba(255, 255, 255, .8);
box-shadow: inset 0px 0px 12px 5px rgba(255, 255, 255, .8);
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
#-webkit-keyframes pulsejg1 {
0% {
-webkit-transform: scale(.6);
opacity: 0;
}
50% {
-webkit-transform: scale(.6);
opacity: 0;
}
60% {
-webkit-transform: scale(.9);
opacity: .2;
}
70% {
-webkit-transform: scale(1.1);
opacity: .35;
}
80% {
-webkit-transform: scale(1.25);
opacity: .2;
}
100% {
-webkit-transform: scale(1.4);
opacity: 0;
}
}
#-moz-keyframes pulsejg1 {
0% {
-moz-transform: scale(.6);
opacity: 0;
}
50% {
-moz-transform: scale(.6);
opacity: 0;
}
60% {
-moz-transform: scale(.9);
opacity: .2;
}
70% {
-moz-transform: scale(1.1);
opacity: .35;
}
80% {
-moz-transform: scale(1.25);
opacity: .2;
}
100% {
-moz-transform: scale(1.4);
opacity: 0;
}
}
#keyframes pulsejg1 {
0% {
transform: scale(.6);
opacity: 0;
}
50% {
transform: scale(.6);
opacity: 0;
}
60% {
transform: scale(.9);
opacity: .1;
}
70% {
transform: scale(1.1);
opacity: .25;
}
80% {
transform: scale(1.25);
opacity: .1;
}
100% {
transform: scale(1.4);
opacity: 0;
}
}
#-webkit-keyframes pulsejg2 {
0% {
-webkit-transform: scale(.6);
opacity: 0;
}
40% {
-webkit-transform: scale(.8);
opacity: .05;
}
50% {
-webkit-transform: scale(1);
opacity: .1;
}
60% {
-webkit-transform: scale(1.1);
opacity: .3;
}
80% {
-webkit-transform: scale(1.2);
opacity: .1;
}
100% {
-webkit-transform: scale(1.3);
opacity: 0;
}
}
#-moz-keyframes pulsejg2 {
0% {
-moz-transform: scale(.6);
opacity: 0;
}
40% {
-moz-transform: scale(.8);
opacity: .05;
}
50% {
-moz-transform: scale(1);
opacity: .1;
}
60% {
-moz-transform: scale(1.1);
opacity: .3;
}
80% {
-moz-transform: scale(1.2);
opacity: .1;
}
100% {
-moz-transform: scale(1.3);
opacity: 0;
}
}
#keyframes pulsejg2 {
0% {
transform: scale(.6);
opacity: 0;
}
40% {
transform: scale(.8);
opacity: .05;
}
50% {
transform: scale(1);
opacity: .1;
}
60% {
transform: scale(1.1);
opacity: .3;
}
80% {
transform: scale(1.2);
opacity: .1;
}
100% {
transform: scale(1.3);
opacity: 0;
}
}
// end profile picture
You used % value for margins its why when you re-size your browser, your picture move. Use instead margin: 0px auto to always keep it on middle and % top to always keep it 20 % from top no mater what screen size you device have. I guess you want this picture to be placed exactly on middle. Its how your code should looks like:
.profilepicture
{
position: absolute;
width: 180px;
height: 180px;
margin: 0px auto;
top: 20%;
left: 0;
right: 0;
bottom: 0;
background: url(/../assets/img/AdolfoBarreto.4.jpg) no-repeat;
background-size: 180px 180px;
z-index: 3;
box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.2), 0 0 5px 2px rgba(0, 0, 0, 0.3), inset 0 0 0 10px rgba(0, 0, 255, 0.2);
border-radius: 999px;}
Same thing with this animation which you placed there. By this, you will keep image always on middle.
You have used margin-top: 10%; and margin-left: 44.6%; as percentage that causes to move the picture when the window resizes. Change it to pixels, and you can also remove left margins and add margin: auto; instead.
Change:
.profilepicture {
margin-top: 10%;
margin-left: 44.6%;
}
To:
.profilepicture {
margin: auto;
}

How to show tool tip on to the left side of DIV

Hello I have downloaded some codes from Google for a Tool tip for one of my DIVs.
In here the Tool tip is displaying on the top of DIV what I want is to display the Tool
tip on the left side of DIV and should has a long height.
I am Beginner to CSS i tried my best but I couldn't found the solution for it.
Please check the JSFIDDLE Link
CSS Code
.wrapper {
text-transform: uppercase;
background: #ececec;
color: #555;
cursor: help;
font-family: "Gill Sans", Impact, sans-serif;
font-size: 20px;
padding: 15px 20px;
position: relative;
width: 200px;
-webkit-transform: translateZ(0); /* webkit flicker fix */
-webkit-font-smoothing: antialiased; /* webkit text rendering fix */
}
.wrapper .tooltip {
background: #1496bb;
bottom: 100%;
color: #fff;
display: block;
left: -25px;
margin-bottom: 15px;
opacity: 0;
padding: 20px;
pointer-events: none;
position: absolute;
width: 100%;
-webkit-transform: translateY(10px);
-moz-transform: translateY(10px);
-ms-transform: translateY(10px);
-o-transform: translateY(10px);
transform: translateY(10px);
-webkit-transition: all .25s ease-out;
-moz-transition: all .25s ease-out;
-ms-transition: all .25s ease-out;
-o-transition: all .25s ease-out;
transition: all .25s ease-out;
-webkit-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
-moz-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
-ms-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
-o-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
}
/* This bridges the gap so you can mouse into the tooltip without it disappearing */
.wrapper .tooltip:before {
bottom: -20px;
content: " ";
display: block;
height: 20px;
left: 0;
position: absolute;
width: 100%;
}
/* CSS Triangles - see Trevor's post */
.wrapper .tooltip:after {
border-left: solid transparent 10px;
border-right: solid transparent 10px;
border-top: solid #1496bb 10px;
bottom: -10px;
content: " ";
height: 0;
left: 50%;
margin-left: -13px;
position: absolute;
width: 0;
}
.wrapper:hover .tooltip {
opacity: 1;
pointer-events: auto;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-o-transform: translateY(0px);
transform: translateY(0px);
}
/* IE can just show/hide with no transition */
.lte8 .wrapper .tooltip {
display: none;
}
.lte8 .wrapper:hover .tooltip {
display: block;
}
HTML Code
<br /><br /><br /><br /><br /><br /><br /><br />
<div class="wrapper">
<div class="tooltip">Here is the massage to be shown to the user Here is the massage to be shown to the user</div>
</div>
</div>
If I understood right, here's what you need:
http://jsfiddle.net/n6scfd6n/
.wrapper {
text-transform: uppercase;
background: #ececec;
color: #555;
cursor: help;
font-family:"Gill Sans", Impact, sans-serif;
font-size: 20px;
padding: 15px 20px;
position: relative;
width: 200px;
-webkit-transform: translateZ(0);
/* webkit flicker fix */
-webkit-font-smoothing: antialiased;
/* webkit text rendering fix */
margin-left: 15em;
}
.wrapper .tooltip {
background: #1496bb;
color: #fff;
display: block;
margin-bottom: 15px;
padding: 20px;
position: absolute;
width: 100%;
-webkit-transform: translateY(10px);
-moz-transform: translateY(10px);
-ms-transform: translateY(10px);
-o-transform: translateY(10px);
transform: translateY(10px);
-webkit-transition: all .25s ease-out;
-moz-transition: all .25s ease-out;
-ms-transition: all .25s ease-out;
-o-transition: all .25s ease-out;
transition: all .25s ease-out;
-webkit-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
-moz-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
-ms-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
-o-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
margin-left: -16em;
margin-top: -4em;
opacity: 0;
}
/* This bridges the gap so you can mouse into the tooltip without it disappearing */
.wrapper .tooltip:before {
bottom: -20px;
content:" ";
display: block;
height: 20px;
left: 0;
position: absolute;
width: 100%;
}
/* CSS Triangles - see Trevor's post */
.wrapper .tooltip:after {
border-top: solid transparent 10px;
border-bottom: solid transparent 10px;
border-left: solid #1496bb 10px;
bottom: calc(50% - 5px);
content: " ";
height: 0;
left: 100%;
margin-left: 0px;
position: absolute;
width: 0;
}
.wrapper:hover .tooltip {
opacity: 1;
pointer-events: auto;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-o-transform: translateY(0px);
transform: translateY(0px);
}
/* IE can just show/hide with no transition */
.lte8 .wrapper .tooltip {
display: none;
}
.lte8 .wrapper:hover .tooltip {
display: block;
}
Just updated -
http://jsfiddle.net/t570goyv/4/
.wrapper .tooltip:after {
border-bottom: solid transparent 10px;
border-top: solid transparent 10px;
border-left: solid #1496bb 10px;
bottom: 60px;
content: " ";
height: 0;
left: 104%;
margin-left: -13px;
position: absolute;
width: 0;
}
Check this working demo and let me know if its matching your requirement or not. I have just positioned the tooltip and arrow element, and changed the css animation from transitionY to transitionX.
CSS :
.wrapper {
text-transform: uppercase;
background: #ececec;
color: #555;
cursor: help;
font-family: "Gill Sans", Impact, sans-serif;
font-size: 20px;
float:right;
padding: 15px 20px;
position: relative;
width: 200px;
-webkit-transform: translateZ(0); /* webkit flicker fix */
-webkit-font-smoothing: antialiased; /* webkit text rendering fix */
}
.wrapper .tooltip {
background: #1496bb;
right: 110%;
color: #fff;
display: block;
opacity: 0;
padding: 20px;
pointer-events: none;
position: absolute;
width: 100%;
top: -180%;
-webkit-transform: translateX(10px);
-moz-transform: translateX(10px);
-ms-transform: translateX(10px);
-o-transform: translateX(10px);
transform: translateX(10px);
-webkit-transition: all .25s ease-out;
-moz-transition: all .25s ease-out;
-ms-transition: all .25s ease-out;
-o-transition: all .25s ease-out;
transition: all .25s ease-out;
-webkit-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
-moz-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
-ms-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
-o-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
}
/* This bridges the gap so you can mouse into the tooltip without it disappearing */
.wrapper .tooltip:before {
bottom: -20px;
content: " ";
display: block;
height: 20px;
left: 0;
position: absolute;
width: 100%;
}
/* CSS Triangles - see Trevor's post */
.wrapper .tooltip:after {
border-top: solid transparent 10px;
border-bottom: solid transparent 10px;
border-left: solid #1496bb 10px;
content: " ";
height: 0;
top: 45%;
right:-10px;
position: absolute;
width: 0;
}
.wrapper:hover .tooltip {
opacity: 1;
pointer-events: auto;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-o-transform: translateY(0px);
transform: translateY(0px);
}
/* IE can ju
st show/hide with no transition */
.lte8 .wrapper .tooltip {
display: none;
}
.lte8 .wrapper:hover .tooltip {
display: block;
}
Hope it helps.

Css Carousel Issues

i am developing my custom site and have developed a pure css Carousel. There is one problem that whenever i navigate to second image the position does not remain fixed. :( it changes to bottom i mean the position changes to bottom.Please help me to fix this and Is there any way to add auto-scrolling in it?? This is the code:
Html:
<div id="slider">
<!-- Sildes -->
<img id="one" src="image Url 1" />
<img id="two" src="image Url 2" />
<img id="three" src="image Url 3" />
<img id="four" src="image Url 4" />
<img id="five " src="image Url 5" />
<!-- Links for the slides! -->
<ul>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
</ul>
</div>
Css:
#slider {
width: 640px;
height: 320px;
margin: 50px auto 0;
position: relative;
background: #fff;
box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.2);
}
#slider:before, #slider:after {
content: '';
position: absolute;
width: 60%;
height: 20px;
-webkit-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
-ms-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
-o-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
-webkit-transform: rotate(-4deg) skew(-10deg);
-moz-transform: rotate(-4deg) skew(-10deg);
-o-transform: rotate(-4deg) skew(-10deg);
-ms-transform: rotate(-4deg) skew(-10deg);
transform: rotate(-4deg) skew(-10deg);
left: 10px;
bottom: 13px;
z-index: -1;
}
#slider:after {
left: auto;
right: 10px;
-webkit-transform: rotate(4deg) skew(10deg);
-moz-transform: rotate(4deg) skew(10deg);
-o-transform: rotate(4deg) skew(10deg);
-ms-transform: rotate(4deg) skew(10deg);
transform: rotate(4deg) skew(10deg);
}
#slider ul {
width: 140px;
height: 40px;
padding: 0 0 0 0;
position: absolute;
z-index: 10;
list-style: none;
left: 50%;
margin-left: -70px;
bottom: -60px;
}
#slider ul li:first-child {
margin-left: 16px;
}
#slider ul li {
float: left;
margin-right: 12px;
margin-top: 14px;
}
#slider ul li:last-child {
margin-right: 0;
}
#slider ul li a {
width: 12px;
height: 12px;
display: block;
outline: none;
border: none;
position: relative;
z-index: 2;
background: #aaa;
box-shadow: inset 0 1px 1px 0px rgba(0, 0, 0, 0.6), 0px 1px 1px 0px white;
-moz-box-shadow: inset 0 1px 1px 0px rgba(0, 0, 0, 0.6), 0px 1px 1px 0px white;
-webkit-box-shadow: inset 0 1px 1px 0px rgba(0, 0, 0, 0.6), 0px 1px 1px 0px white;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
}
#slider ul li a:hover {
background: #888;
}
#slider img {
position: absolute;
left: 0;
top: 0;
opacity: 0;
-webkit-transform: rotateZ(-10deg);
-moz-transform: rotateZ(-10deg);
-ms-transform: rotateZ(-10deg);
-o-transform: rotateZ(-10deg);
transform: rotateZ(-10deg);
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-ms-transition: all .5s ease;
-o-transition: all .5s ease;
transition: all .5s ease;
}
#slider img:target {
opacity: 1;
-webkit-transform: rotateZ(0);
-moz-transform: rotateZ(0);
-ms-transform: rotateZ(0);
-o-transform: rotateZ(0);
transform: rotateZ(0);
}
#slider img#five {
opacity: 1;
-webkit-transform: rotateZ(0);
-moz-transform: rotateZ(0);
-ms-transform: rotateZ(0);
-o-transform: rotateZ(0);
transform: rotateZ(0);}
#slider img:not(:target), #slider img:target ~ img#five {
opacity: 0;
-webkit-transform: rotateZ(-10deg);
-moz-transform: rotateZ(-10deg);
-ms-transform: rotateZ(-10deg);
-o-transform: rotateZ(-10deg);
transform: rotateZ(-10deg);
}
#slider ul li a[href="#five"] {
background: #777;
}
#one:target ~ ul li a[href="#one"],
#two:target ~ ul li a[href="#two"],
#three:target ~ ul li a[href="#three"],
#four:target ~ ul li a[href="#four"],
#five:target ~ ul li a[href="#five"] {
background: #777;
}
#two:target ~ ul li a[href="#five"],
#three:target ~ ul li a[href="#five"],
#four:target ~ ul li a[href="#five"],
#one:target ~ ul li a[href="#five"] {
background: #aaa;
}
http://jsfiddle.net/NaL88/
Nice work.
I Don't understand you issue with the bottom. I cant find a problem (using chrome).
for auto-scroll, if you are trying no javascript than you could apply css animation using keyframes on hover.
regarding css selectors, use child selector (a > b) when possible. its more efficient than descendant selector (a b)
by the way, here is variation of the carousel with no li elements wrapping the anchor, using display: inline:block. less DOM depth , less elements = more efficient
fiddle
HTML:
<div id="slider">
<!-- Sildes -->
<img id="one" src="http://cssdeck.com/uploads/media/items/3/3yiC6Yq.jpg" />
<img id="two" src="http://cssdeck.com/uploads/media/items/4/40Ly3VB.jpg" />
<img id="three" src="http://cssdeck.com/uploads/media/items/0/00kih8g.jpg" />
<img id="four" src="http://cssdeck.com/uploads/media/items/2/2rT2vdx.jpg" />
<img id="five" src="http://cssdeck.com/uploads/media/items/8/8k3N3EL.jpg" />
<!-- Links for the slides! -->
<section>
</section>
</div>
CSS:
#slider {
width: 640px;
height: 320px;
margin: 50px auto 0;
position: relative;
background: #fff;
box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.2);
-moz-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.2);
-webkit-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.2);
}
#slider:before, #slider:after {
content: '';
position: absolute;
width: 60%;
height: 20px;
-webkit-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
-ms-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
-o-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
-webkit-transform: rotate(-4deg) skew(-10deg);
-moz-transform: rotate(-4deg) skew(-10deg);
-o-transform: rotate(-4deg) skew(-10deg);
-ms-transform: rotate(-4deg) skew(-10deg);
transform: rotate(-4deg) skew(-10deg);
left: 10px;
bottom: 13px;
z-index: -1;
}
#slider:after {
left: auto;
right: 10px;
-webkit-transform: rotate(4deg) skew(10deg);
-moz-transform: rotate(4deg) skew(10deg);
-o-transform: rotate(4deg) skew(10deg);
-ms-transform: rotate(4deg) skew(10deg);
transform: rotate(4deg) skew(10deg);
}
#slider section {
width: 140px;
height: 40px;
padding: 0 0 0 0;
position: absolute;
z-index: 10;
list-style: none;
left: 50%;
margin-left: -70px;
bottom: -60px;
}
#slider > section > a {
width: 12px;
height: 12px;
display: inline-block;
outline: none;
border: none;
position: relative;
z-index: 2;
background: #aaa;
box-shadow: inset 0 1px 1px 0px rgba(0,0,0,0.6), 0px 1px 1px 0px white;
-moz-box-shadow: inset 0 1px 1px 0px rgba(0,0,0,0.6), 0px 1px 1px 0px white;
-webkit-box-shadow: inset 0 1px 1px 0px rgba(0,0,0,0.6), 0px 1px 1px 0px white;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
}
#slider > section > a:hover {
background: #888;
}
#slider img {
position: absolute;
left: 0;
top: 0;
opacity: 0;
-webkit-transform: scale(1.2,1.2);
-moz-transform: scale(1.2,1.2);
-ms-transform: scale(1.2,1.2);
-o-transform: scale(1.2,1.2);
transform: scale(1.2,1.2);
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-ms-transition: all .5s ease;
-o-transition: all .5s ease;
transition: all .5s ease;
}
#slider img:target {
opacity: 1;
-webkit-transform: scale(1,1);
-moz-transform: scale(1,1);
-ms-transform: scale(1,1);
-o-transform: scale(1,1);
transform: scale(1,1);
}
#slider img#five {
opacity: 1;
-webkit-transform: scale(1,1);
-moz-transform: scale(1,1);
-ms-transform: scale(1,1);
-o-transform: scale(1,1);
transform: scale(1,1);
}
#slider img:not(:target), #slider img:target ~ img#five {
opacity: 0;
-webkit-transform: scale(1.2,1.2);
-moz-transform: scale(1.2,1.2);
-ms-transform: scale(1.2,1.2);
-o-transform: scale(1.2,1.2);
transform: scale(1.2,1.2);
}
#slider > section > a[href="#five"] {
background: #777;
}
#one:target ~ section > a[href="#one"],
#two:target ~ section > a[href="#two"],
#three:target ~ section > a[href="#three"],
#four:target ~ section > a[href="#four"],
#five:target ~ section > a[href="#five"] {
background: #777;
}
#two:target ~ section > a[href="#five"],
#three:target ~ section > a[href="#five"],
#four:target ~section > a[href="#five"],
#one:target ~ section > a[href="#five"] {
background: #aaa;
}