JSFiddle - React, Tailwind, and code Playground
Guided tour tool-tip
by Jennifer Perrin
HTML
<div class='container'>
<h1>Guided tour tooltip</h1>
<span class='close'></span>
<div class='slider-container'>
<div class='slider-turn'>
<p>Guided tour tooltip inspired by Jonathan Moreira</p>
<p>
Dribbble shot visible at
<a href='http://dribbble.com/shots/1216346-Guided-tour-tooltip' target='_blank' title='Dribbble shot'>this link</a>
</p>
<p>Codepen by Yoann Helin</p>
<p>
<a href='https://twitter.com/YoannHELIN' target='_blank' title='Twitter'>Twitter : @YoannHELIN</a>
<br>
<a href='http://yoannhelin.fr' target='_blank' title='Book'>Book : Yoannhelin.fr</a>
</p>
<p>Thank you !</p>
</div>
</div>
<div class='bottom'>
<div class='step'>
<span></span>
<ul>
<li data-num='1'></li>
<li data-num='2'></li>
<li data-num='3'></li>
<li data-num='4'></li>
<li data-num='5'></li>
</ul>
</div>
<button class='btn'>Next</button>
</div>
</div>
<button class='open'>
Open
</button>
CSS
@import url(http://fonts.googleapis.com/css?family=Muli);
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background-color: #B6BCC9;
font-family: 'Muli';
}
* {
outline: none;
}
h1 {
font-size: 25px;
font-weight: 100;
color: #2C2C2C;
margin: 20px 25px;
}
a {
text-decoration: none;
color: #3476CA;
}
a:hover {
color: #6CB5F3;
}
.open {
position: fixed;
width: 100px;
height: 40px;
left: 50%;
top: -1000px;
margin-left: -80px;
margin-top: -30px;
border: 1px solid #ccc;
background-color: #fff;
border-radius: 6px;
padding: 10px 30px;
color: #444;
transition: all ease-out 0.6s;
}
.open:hover {
border: 1px solid #aaa;
box-shadow: 0 0 8px #ccc inset;
transition: all ease-out 0.6s;
}
.container {
position: fixed;
width: 400px;
height: 238px;
left: 50%;
top: 50%;
margin-top: -119px;
margin-left: -200px;
background-color: #F3F3F3;
border-radius: 6px;
box-shadow: 0px 0px 24px rgba(0, 0, 0, 0.4);
}
.container:before {
content: '';
position: absolute;
left: -14px;
top: 28px;
border-style: solid;
border-width: 10px 14px 10px 0;
border-color: rgba(0, 0, 0, 0) #f3f3f3 rgba(0, 0, 0, 0) rgba(0, 0, 0, 0);
}
.container p {
width: 350px;
font-size: 16px;
color: #a8aab2;
font-weight: 400;
line-height: 28px;
float: left;
margin: 0;
}
.container .bottom {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
width: 100%;
bottom: 0;
position: absolute;
}
.container .bottom .step {
flex: 3;
-webkit-flex: 3;
-ms-flex: 3;
width: 100%;
height: 54px;
background-color: #373942;
border-bottom-left-radius: 6px;
display: flex;
}
.container .bottom .step span {
flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
line-height: 54px;
color: #fff;
margin-left: 25px;
font-size: 18px;
}
.container .bottom .step ul {
flex: 2;
-webkit-flex: 2;
-ms-flex: 2;
list-style: none;
height: 10px;
margin: 23px 0;
...
JavaScript
$(document).ready(function () {
var nbP = $('.container p').length;
var w = parseInt($('.container p').css("width"));
var max = (nbP - 1) * w;
$("ul li[data-num='1']").addClass('active');
$('.step span').html('Step 1');
$('body').on('click','.btn', function(){
var margL = parseInt($('.slider-turn').css('margin-left'));
var modulo = margL%w;
if (-margL < max && modulo == 0) {
margL -= w;
$('.slider-turn').animate({
'margin-left':margL
},300);
$('ul li.active').addClass('true').removeClass('active');
var x = -margL/w +1;
$('ul li[data-num="'+x+'"]').addClass('active');
$('.step span').html("Step "+x);
}
else {}
});
$('body').on('click','.close',function(){
$('.container').animate({
'opacity':0
},600);
$('.container').animate({
'top':-1200
}, {
duration: 2300,
queue: false
});
$('.open').animate({
'top':'50%'
});
});
$('body').on('click','.open',function() {
$('.open').animate({
'top':-1000
});
$('.container').animate({
'opacity':1
},400);
$('.container').animate({
'top':'50%'
}, {
duration: 800,
queue: false
});
});
});