CSS Only Multiple onclick events - html

This is generally a hack which i am trying to figure out in css, From what I can gather it should be working in theory and it isn't.
#expand {
width: 30px;
height: 30px;
background-color: rgba(0, 0, 0, 0);
}
#btn {
display: none;
}
#btn:checked+label:before {
transform: rotate(90deg);
}
#btn:checked+label:after {
transform: rotate(180deg);
}
#btn:checked+.button:before {
display: none;
}
#btn:checked+.button:after {
display: inline-block;
}
.button {
position: relative;
width: 25px;
height: 25px;
display: inline-block;
}
.button:before,
.button:after {
content: "";
position: absolute;
background-color: black;
transition: transform 0.35s ease-out;
}
/* Vert Line */
.button:before {
top: 0;
left: 46%;
width: 4px;
height: 100%;
margin-left: 2px;
margin-top: 2px;
}
/* Horiz Line */
.button:after {
top: 50%;
left: 0;
width: 100%;
height: 4px;
margin-left: 2px;
}
.inform {
display: none;
}
<div id="expand">
<input id="btn" type="checkbox">
<label class="button" for="btn"></label>
<div class="inform">
<h3>Heading</h3>
<p>Alot of content.</p>
</div>
So as you can see, I have the "hack" for the click event on changing the style for .button using a checkbox.
I then used the + selector to target the div .inform.
If i am correct the + selector means it targets the immediate following element, In which case this should work. But it does not, Could someone possibly help clear my understanding of this and if i am wrong, otherwise could you help point me in the right direction to get this to work.
Summary:
I would like to get the header and paragraph to display when the checkbox is checked, aswell as getting the + symbol to rotate.

You've got similar selectors:
#btn:checked+.button:before {
display: none;
}
#btn:checked+.button:before {
display: inline-block;
}
And #btn:checked+label:before and #btn:checked+.button:before are the same thing.
I think it should look like:
#expand {
width: 30px;
height: 30px;
background-color: rgba(0, 0, 0, 0);
}
#btn {
display: none;
}
#btn:checked+label:before {
transform: rotate(90deg);
}
#btn:checked+label:after {
transform: rotate(180deg);
}
#btn:checked+.button:before {
display: none;
}
#btn:checked ~ .inform {
opacity: 1;
}
.button {
position: relative;
width: 25px;
height: 25px;
display: inline-block;
}
.button:before,
.button:after {
content: "";
position: absolute;
background-color: black;
transition: transform 0.35s ease-out;
}
/* Vert Line */
.button:before {
top: 0;
left: 46%;
width: 4px;
height: 100%;
margin-left: 2px;
margin-top: 2px;
}
/* Horiz Line */
.button:after {
top: 50%;
left: 0;
width: 100%;
height: 4px;
margin-left: 2px;
}
.inform {
display: inline-block;
opacity: 0;
transition: all .5s ease;
}
<div id="expand">
<input id="btn" type="checkbox">
<label class="button" for="btn"></label>
<div class="inform">
<h3>Heading</h3>
<p>Alot of content.</p>
</div>

Related

Fully responsive progress bar

I have to create a progress bar that has to be fully responsive. In order to be responsive I don't want the progress bar class to have a fixed width, but when I put auto in width, line of progress bar is detached from the star also if I give to them auto width
Fixed width: look good
Width auto
First how can I fix this issue, and perhaps someone can help me achieve this progress bar to be responsive on mobile also so that the line of progress bar will be vertical.
.progress-bar {
width: 750px;
display: flex;
margin: 40px 0;
}
.progress-bar .step {
text-align: center;
width: 100%;
}
.progress-bar .step .bullet {
position: relative;
height: 25px;
width: 25px;
display: inline-block;
}
.progress-bar .step:last-child .bullet:before,
.progress-bar .step:last-child .bullet::after {
display: none;
}
.progress-bar .step .bullet:before,
.progress-bar .step .bullet::after {
position: absolute;
content: "";
height: 3px;
right: -136px;
bottom: 11px;
width: 142px;
background: #C1C1C1;
}
.active-bullet {
z-index: 1;
}
.active-check {
z-index: 2;
}
<div class="progress-bar">
<div class="step">
<div class="bullet active-bullet">
<img src="star-pb-active.svg">
</div>
<div class="check active-check" style="
border-bottom: 2px solid black;
padding: 2px;
DISPLAY: table-cell;
LEFT: 40px;
POSITION: relative;
">Order placed</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Jewerly Creation</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Packing & Quality Control</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Shipped</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Estimated Delivery</div>
</div>
</div>
You should try taking a look at the flex-grow property from Flexbox.
By giving display: flex to the parent, and flex-grow: 1 to the children, you should be able to make every step be the same size and take all the width of their container.
It works the way you want, in fixed or auto width.
.progress-bar {
width: auto;
display: flex;
margin: 40px 0;
}
.progress-bar .step {
text-align: center;
position: relative;
isolation: isolate;
width: 100%;
}
.progress-bar .step::after {
content: "";
position: absolute;
z-index: -1;
height: 3px;
top: 12px; /* 1/2 of .bullet's height */
width: 100%;
background: #C1C1C1;
}
.progress-bar .step:last-child::after {
display: none;
}
.progress-bar .step .bullet {
position: relative;
height: 25px;
width: 25px;
display: inline-block;
}
.active-bullet {
z-index: 1;
}
.active-check {
z-index: 2;
}
Added pseudo element on the parent of .bullet.
Also you don't need ::before, one of those pseudo elements was enough.
try below code, your code some confusion.
use flex in css
below sample add one button which goes your activity to next step
it is fully responsive - on desktop this code horizontal and on mobile this code show vertical progressbar.
just use small js, css and for tick icon font awesome js.
if any query comment it.
let step = 'step1';
const step1 = document.getElementById('step1');
const step2 = document.getElementById('step2');
const step3 = document.getElementById('step3');
const step4 = document.getElementById('step4');
function next() {
if (step === 'step1') {
step = 'step2';
step1.classList.remove("is-active");
step1.classList.add("is-complete");
step2.classList.add("is-active");
} else if (step === 'step2') {
step = 'step3';
step2.classList.remove("is-active");
step2.classList.add("is-complete");
step3.classList.add("is-active");
} else if (step === 'step3') {
step = 'step4d';
step3.classList.remove("is-active");
step3.classList.add("is-complete");
step4.classList.add("is-active");
} else if (step === 'step4d') {
step = 'complete';
step4.classList.remove("is-active");
step4.classList.add("is-complete");
} else if (step === 'complete') {
step = 'step1';
step4.classList.remove("is-complete");
step3.classList.remove("is-complete");
step2.classList.remove("is-complete");
step1.classList.remove("is-complete");
step1.classList.add("is-active");
}
}
.progress-bar {
position: relative;
display: flex;
}
.progress-bar .progress-track {
position: absolute;
top: 5px;
width: 100%;
height: 5px;
background-color: #dfe3e4;
z-index: -1;
}
.progress-bar .progress-step {
position: relative;
width: 100%;
font-size: 12px;
text-align: center;
}
.progress-bar .progress-step:last-child:after {
display: none;
}
.progress-bar .progress-step:before {
content: "\f00c";
display: flex;
margin: 0 auto;
margin-bottom: 10px;
width: 10px;
height: 10px;
background: #fff;
border: 4px solid #dfe3e4;
border-radius: 100%;
color: transparent;
}
.progress-bar .progress-step:after {
content: "";
position: absolute;
top: 6px;
left: 50%;
width: 0%;
transition: width 1s ease-in;
height: 5px;
background: #dfe3e4;
z-index: -1;
}
#media screen and (max-width:700px) {
.progress-bar {
position: relative;
display: inline-block;
}
.progress-bar .progress-track {
position: absolute;
top: -10px;
width: 100%;
height: 5px;
background-color: #dfe3e4;
z-index: -1;
transform: rotate(90deg);
}
.progress-bar .progress-step {
position: relative;
width: 100%;
font-size: 12px;
text-align: center;
}
.progress-bar .progress-step:last-child:after {
display: none;
}
.progrestext
{
left: 44px;
position: absolute;
top: 0px;
}
.progress-bar .progress-step:after {
content: "";
position: absolute;
top: 20px;
left: 0%;
width: 0%;
transition: width 1s ease-in;
height: 5px;
background: #dfe3e4;
z-index: -1;
transform: rotate(90deg);
}
}
.progress-bar .progress-step.is-active {
color: #2183dd;
}
.progress-bar .progress-step.is-active:before {
border: 4px solid #777;
animation: pulse 2s infinite;
}
.progress-bar .progress-step.is-complete {
color: #009900;
}
.progress-bar .progress-step.is-complete:before {
font-family: FontAwesome;
font-size: 10px;
color: #fff;
background: #009900;
border: 4px solid transparent;
}
.progress-bar .progress-step.is-complete:after {
background: #2183dd;
animation: nextStep 1s;
animation-fill-mode: forwards;
}
#keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(33, 131, 221, 0.8);
}
70% {
box-shadow: 0 0 0 10px rgba(33, 131, 221, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(33, 131, 221, 0);
}
}
#keyframes nextStep {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
.container {
margin: 50px 100px;
}
button {
position: absolute;
right: 50px;
bottom: 20px;
cursor: pointer;
}
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://use.fontawesome.com/c47bc38e87.js"></script>
<div class="container">
<div class="progress-bar">
<div class="progress-track"></div>
<div id="step1" class="progress-step">
<div class="progrestext">placed</div>
</div>
<div id="step2" class="progress-step">
<div class="progrestext">Creation</div>
</div>
<div id="step3" class="progress-step">
<div class="progrestext">Packing</div>
</div>
<div id="step4" class="progress-step">
<div class="progrestext">Delivered</div>
</div>
</div>
<button onClick=next()>Next Step</button>
</div>

How to make a custom radio input with label

I am trying to perform a custom radio input for gender, a user can only choose either between "female" and "male", but I realized that I cant see the checked radio to display when I click on it seems not to work (to be selected) when I click on it, I tried to find out what is causing the radio not to be checked but I can't find it out. It used to work with the checkboxes inputs could anyone help me please, I am probably missing something.
.profile__input .input__radio {
display: inline-block;
}
.blu-radio {
width: auto;
margin: 16px 16px 16px 0;
display: inline-flex;
position: relative;
}
.blu-radio:not(.b-disabled) {
cursor: pointer;
}
.blu-radio .blu-radio-container {
width: 20px;
min-width: 20px;
height: 20px;
position: relative;
border: 2px solid transparent;
border-radius: 50%;
transition: .4s cubic-bezier(0.25, 0.8, 0.25, 1);
border-color: #e0e0e0;
}
.blu-radio .blu-radio-container:before,
.blu-radio .blu-radio-container:after {
position: absolute;
transition: .4s cubic-bezier(0.55, 0, 0.55, 0.2);
content: " ";
}
.blu-radio .blu-radio-container:before {
width: 48px;
height: 48px;
top: 50%;
left: 50%;
z-index: 11;
border-radius: 50%;
transform: translate(-50%, -50%);
}
.blu-radio .blu-radio-container input {
position: absolute;
left: -999em;
}
.blu-radio .blu-radio-container:after {
position: absolute;
top: 3px;
right: 3px;
bottom: 3px;
left: 3px;
border-radius: 50%;
opacity: 0;
transform: scale3D(0.38, 0.38, 1);
content: " ";
}
.blu-radio .blu-radio-label {
padding-left: 8px;
position: relative;
line-height: 20px;
}
.blu-radio:not(.b-disabled) .blu-radio-label {
cursor: pointer;
color: rgba(0, 0, 0, 0.6);
}
<div class="profile__input">
<div class="input__title tx-gray">Genre</div>
<div class="input__radio">
<div class="blu-radio">
<div class="blu-radio-container">
<input type="radio" id="blu-radio-3as6fzz1" name='gender'>
</div>
<label for="blu-radio-3as6fzz1" class="blu-radio-label">Homme</label>
</div>
</div>
<div class="input__radio">
<div class="blu-radio">
<div class="blu-radio-container">
<input type="radio" id="blu-radio-v0okyps4r" name='gender'>
</div>
<label for="blu-radio-v0okyps4r" class="blu-radio-label">Femme</label>
</div>
</div>
</div>
Try this code instead, i'm using the input:checked to test if the radio is checked or not then i append to the fake radio a background color.
I put the fake radio container into the label, so when you click on it, it will check the real radio button wich is hidden.
.profile__input .input__radio {
display: inline-block;
}
.blu-radio {
width: auto;
margin: 16px 16px 16px 0;
display: inline-flex;
position: relative;
}
.blu-radio:not(.b-disabled) {
cursor: pointer;
}
.blu-radio .blu-radio-container {
width: 20px;
min-width: 20px;
height: 20px;
position: relative;
border: 2px solid transparent;
border-radius: 50%;
transition: .4s cubic-bezier(0.25, 0.8, 0.25, 1);
border-color: #e0e0e0;
display: inline-block;
position: relative;
top: 6px;
}
.blu-radio .blu-radio-container:before,
.blu-radio .blu-radio-container:after {
position: absolute;
transition: .4s cubic-bezier(0.55, 0, 0.55, 0.2);
content: " ";
}
.blu-radio .blu-radio-container:before {
width: 48px;
height: 48px;
top: 50%;
left: 50%;
z-index: 11;
border-radius: 50%;
transform: translate(-50%, -50%);
}
.blu-radio input {
display: none;
}
.blu-radio .blu-radio-container:after {
position: absolute;
top: 3px;
right: 3px;
bottom: 3px;
left: 3px;
border-radius: 50%;
opacity: 0;
transform: scale3D(0.38, 0.38, 1);
content: " ";
}
.blu-radio .blu-radio-label {
padding-left: 8px;
position: relative;
line-height: 20px;
}
.blu-radio input:checked + .blu-radio-label .blu-radio-container {
background: red;
}
.blu-radio:not(.b-disabled) .blu-radio-label {
cursor: pointer;
color: rgba(0, 0, 0, 0.6);
}
<div class="profile__input">
<div class="input__title tx-gray">Genre</div>
<div class="input__radio">
<div class="blu-radio">
<input type="radio" id="blu-radio-3as6fzz1" name='gender'>
<label for="blu-radio-3as6fzz1" class="blu-radio-label">
<span class="blu-radio-container"></span> Homme
</label>
</div>
</div>
<div class="input__radio">
<div class="blu-radio">
<input type="radio" id="blu-radio-v0okyps4r" name='gender'>
<label for="blu-radio-v0okyps4r" class="blu-radio-label">
<span class="blu-radio-container"></span> Femme
</label>
</div>
</div>
</div>
a basic one...
* {
font-size : 20px;
}
label > input[type="radio"] { display : none; }
label > input[type="radio"] + span {
--diameter : 1.4em;
display : inline-block;
height : var(--diameter);
line-height : var(--diameter);
cursor : pointer;
width : 6.2em;
position : relative;
box-sizing : border-box;
padding-left : calc(var(--diameter) + .3em);
color : #7d7d7d;
}
label > input[type="radio"]:checked + span {
color : black;
}
label > input[type="radio"] + span:before {
box-sizing : border-box;
width : var(--diameter);
height : var(--diameter);
border : 1px solid #7d7d7d;
border-radius : 50%;
position : absolute;
top : 0;
left : 0;
content : ' ';
}
label > input[type="radio"]:checked + span::after {
box-sizing : border-box;
position : absolute;
top : .1em;
left : .1em;
content : ' ';
width : calc(var(--diameter) - .2em);
height : calc(var(--diameter) - .2em);
border-radius : 50%;
background-color : #eb1641;
}
<label>
<input type="radio" name="gender">
<span>Homme</span>
</label>
<label>
<input type="radio" name="gender">
<span>Femme</span>
</label>

Custom checkboxes move slightly when selected

I modified the checkboxes in my project to look more aligned with the rest of the design but I have a problem: whenever selected the label of the checkbox moves slightly.
input[type="checkbox"] {
display: none !important;
}
input[type="checkbox"]+label:before {
position: relative;
content: " ";
display: inline-block;
width: 22px;
height: 22px;
border: 1px solid grey;
top: 4px;
margin: 0 10px 0 0;
}
input[type="checkbox"]:checked+label:before {
position: relative;
content: "✔";
display: inline-block;
width: 22px;
height: 22px;
border: 1px solid grey;
top: 4px;
margin: 0 10px 0 0;
}
<input type="checkbox" />
<label>Click to accept</label>
Here's the result:
And here's what happens if I select it:
What am I doing wrong?
Nowadays and for awhile you can fix this if you set the parent to display:flex
input[type="checkbox"] {
display: none !important;
}
label {
display: flex;
/* just to vertically the text with the box */
align-items: center
}
input[type="checkbox"]+label::before {
content: "";
display: block;
width: 22px;
height: 22px;
border: 1px solid grey;
margin: 0 10px 0 0;
}
input[type="checkbox"]:checked+label::before {
content: "✔";
/* just to center inside the box */
display: grid;
place-content: center;
}
<input id="input" type="checkbox" />
<label for="input">Click to accept</label>
OLD ANSWER
To fix the "moving" you need to:
set vertical-align: some value in label::before I have choose bottom.
And to align the "✔" (in case it doesn't - snippet isn't), you need to:
add text-align:center and line-height:22px (same as the height) in :checked+label::before
input[type="checkbox"] {
display: none !important;
}
input[type="checkbox"]+label::before {
position: relative;
content: " ";
display: inline-block;
vertical-align: bottom;
width: 22px;
height: 22px;
border: 1px solid grey;
top: 4px;
margin: 0 10px 0 0;
}
input[type="checkbox"]:checked+label::before {
content: "✔";
text-align: center;
line-height: 22px;
}
<input id="input" type="checkbox" />
<label for="input">Click to accept</label>
NB: In both answers I removed duplicated properties and you're missing the for attribute in label to match id in input, otherwise you can't click in the pseudo checkbox, only in the label
You can see another way here.
See below working example:
/*--CSS--*/
input[type="checkbox"] {
-webkit-appearance: none;
background-color: transparent;
-webkit-rtl-ordering: logical;
user-select: text;
cursor: pointer;
padding: 1px;
border-width: 0;
border-style: inset;
border-color: initial;
border-image: initial;
float: left;
margin: 0 25px 0 0;
position: relative;
}
input[type="checkbox"]:after {
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
content: "";
position: absolute;
left: 0;
z-index: 1;
width: 16px;
height: 16px;
border: 1px solid #c0c0c0;
top:0;
}
input[type="checkbox"]:before {
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
content: "";
position: absolute;
left: 0;
z-index: 1;
width: 16px;
height: 16px;
border: 1px solid #c0c0c0;
top:0;
opactity:0;
}
input[type="checkbox"]:checked:before {
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
height: 5px;
border-color: #009688;
border-top-style: none;
border-right-style: none;
outline: none;
opacity: 1;
width: 12px;
top: 3px;
left: 3px;
}
input[type="checkbox"]:focus{outline:0;}
<!--HTML-->
<input type="checkbox" />
<label>Click to accept</label>
I have used a flexbox for the label to align the items vertically. Adding text-align:center when the checkbox is checked, ensures the marker is horizontally centered.
label {
display: flex;
align-items: center;
}
input[type="checkbox"] {
display: none;
}
input[type="checkbox"]+label:before {
content: " ";
display: inline-block;
width: 22px;
height: 22px;
border: 1px solid grey;
margin-right: 0.5em;
}
input[type="checkbox"]:checked+label:before {
content: "✔";
display: inline-block;
width: 22px;
height: 22px;
border: 1px solid grey;
margin-right: 0.5em;
text-align: center;
}
<input type="checkbox" id="accept" />
<label for="accept">Click to accept</label>
you can try this, this is working
input[type="checkbox"] {
position: absolute;
width: 100%;
height: 100%;
opacity: 0;
}
input[type="checkbox"] + label:before {
position: relative;
content: " ";
display: inline-block;
width: 22px;
height: 22px;
border: 1px solid grey;
top: 4px;
margin: -8px 10px 0 0;
vertical-align: middle;
}
input[type="checkbox"]:checked + label:before {
content: "✔";
text-align: center;
line-height: 22px;
}
<input type="checkbox"/>
<label>Click to accept</label>

Create 'X' with using CSS transform-origin and rotate

I have a small issue, I need to rotate 2 spans and create a perfect 'X'.
I've created a JSfiddle for this. Can you guys help me?
I can't seem to get my head around how much should i transform origin...
HTML
<div class="toggle-btn">
<span></span>
<span></span>
</div>
SASS
.toggle-btn {
width: 38px;
height: 19px;
cursor: pointer;
position: relative;
margin-top: 18px;
text-align: center;
&:after {
content: '';
display: block;
clear: both;
}
span {
height: 2px;
margin: 5px 0px;
background: #333;
width: 100%;
display: block;
transition: .15s ease-in;
text-align: center;
&.toggled {
&:nth-of-type(1) {
transform: rotate(-45deg);
transform-origin: 22px 9px;
}
&:nth-of-type(2) {
transform: rotate(45deg);
transform-origin: 20px -5px;
}
}
}
}
and JS
$('.toggle-btn').on('click',function(){
$(this).find('span').toggleClass('toggled');
});
This appears to work. I had to adjust the margin to 4px. The rotation needs to come after the x/y translation because translating after the rotation appears to change the point of origin on which the element is rotating instead of origin of the element. You can observe this behavior by trying a large (100px) x-translation after the rotation.
.toggle-btn {
width: 38px;
height: 19px;
cursor: pointer;
position: relative;
margin-top: 18px;
text-align: center;
overflow: show;
&:after {
content: '';
display: block;
clear: both;
}
span {
height: 2px;
margin: 4px 0px;
background: #333;
width: 38px;
display: block;
transition: .15s ease-in;
text-align: center;
&.toggled {
&:nth-of-type(1) {
transform: translate(0px, 3px) rotate(-45deg);
}
&:nth-of-type(2) {
transform: translate(0px, -3px) rotate(45deg);
}
}
}
}

Show tooltip only on hover

I've made some tooltips for my dot navigation. The are now visible, but I want them to only be visible on hover.
What am I doing wrong?
I've played a bit with display: none and visibility but when I make a code like this:
span.tooltip {
display: none;
}
span.tooltip:hover {
display: block;
}
Nothing happens, they aren't visible at all.
Here's a JSFiddle. http://jsfiddle.net/hEZmE/
HTML
<div id="cbp-fbscroller" class="cbp-fbscroller">
<nav>
<span class="tooltip">Home</span>
<span class="tooltip">De mogelijkheden</span>
<span class="tooltip">Restauratie</span>
<span class="tooltip">Het proces</span>
<span class="tooltip">Werkplaats</span>
<span class="tooltip">Ambacht en Handwerk</span>
<span class="tooltip">Contact</span>
</nav>
<section id="fbsection1"></section>
<section id="fbsection2"></section>
<section id="fbsection3"></section>
<section id="fbsection4"></section>
<section id="fbsection5"></section>
<section id="fbsection6"></section>
<section id="fbsection7"></section>
CSS
.cbp-fbscroller > nav {
position: fixed;
z-index: 9999;
right: 50px;
top: 50%;
width: 10px;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.cbp-fbscroller > nav a {
display: block;
position: relative;
z-index: 9999;
color: transparent;
width: 10px;
height: 10px;
outline: none;
margin: 25px 0;
border-radius: 50%;
border: 1px solid #333;
}
.no-touch .cbp-fbscroller > nav a:hover {
background: #333;
}
.cbp-fbscroller > nav a.cbp-fbcurrent {
background: #333;
}
#fbsection1 {
background-color: #ccc;
height: 800px;
}
#fbsection2 {
background-color: #aaa;
height: 800px;
}
#fbsection3 {
background-color: #ccc;
height: 800px;
}
#fbsection4 {
background-color: #aaa;
height: 800px;
}
#fbsection5 {
background-color: #ccc;
height: 800px;
}
#fbsection6 {
background-color: #aaa;
height: 800px;
}
#fbsection7 {
background-color: #ccc;
height: 800px;
}
span.tooltip {
position: absolute;
margin-top: -6px;
margin-left: -120px;
width: 100px;
height: 20px;
line-height: 20px;
font-size: 12px;
text-align: center;
color: #fff;
background: #333;
}
For one thing, your code doesn't work as is because you've applied your hover event to the tooltip, which is not displayed—you can't hover over something that isn't there (as berentrom pointed out) .
span.tooltip {
display: none;
}
span.tooltip:hover {
display: block;
}
What you're trying to do is show the tooltip when you hover over the dot, so you need to tie the hover event to the dot, and not to the tooltip.
Add this to your CSS:
span.tooltip {
display: none;
}
#cbp-fbscroller a:hover > span.tooltip {
display: block;
}
See here: http://jsfiddle.net/hEZmE/4/