Skip to content

Instantly share code, notes, and snippets.

@diegozr1
Last active August 25, 2016 21:47
Show Gist options
  • Save diegozr1/4c4ca363898e3f3b7ee58fd8bae9622d to your computer and use it in GitHub Desktop.
Save diegozr1/4c4ca363898e3f3b7ee58fd8bae9622d to your computer and use it in GitHub Desktop.
Create a popup when a mouse hovers a link in a website
<!DOCTYPE html>
<html>
<head>
<title>Here</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="profile">
<span class="label">Profile</span>
<div class="popup">
<div class="user">
<img class="photo" src="http://cf4.merca20.com/wp-content/uploads/2015/09/Mario-Bros.jpg">
<span class="name">Mario Bros.</span>
</div>
<div class="gallery">
<span class="title">Gallery</span>
<img class="photo" src="http://flapyinjapan.com/wp-content/uploads/2011/04/Flag-of-Japan.png">
<img class="photo" src="http://b.tile.opencyclemap.org/cycle/5/28/11.png">
<img class="photo" src="http://www.dndjunkie.com/civilopedia/images/large/CIVILIZATION_JAPAN.png">
</div>
</div>
</div>
</body>
</html>
html,body{
height: 100%;
margin:0;
font-size:16px;
font-family:'Century';
}
.profile .label{
display:block;
position: absolute;
left: calc(50% - .5em - 50px);
top: calc(50% - .5em - .5em);
text-align:center;
background-color:#26A65B;
color:#CCC;
font-size:1em;
padding:1em;
border-radius:.3em;
width: 100px;
}
.profile .popup{
display:none;
position:absolute;
left: calc(50% - 150px - .5em);
top:calc(50% + -16em + 1em + .5em);
border: 1px solid #26A65B;
width:300px;
padding: .5em;
border-top-left-radius:.8em;
border-top-right-radius:.8em;
}
.profile:hover .popup{
display: block;
}
.profile .popup .user .photo{
float: left;
width: 70px;
border-radius: 100%;
}
.profile .popup .user .name{
padding-left: 1em;
float:left;
line-height:70px;
vertical-align:middle;
}
.profile .popup .gallery{
display: block;
clear: both;
padding-top:1em;
width:inherit;
}
.profile .popup .gallery .title{
display: block;
padding-bottom:1em;
}
.profile .popup .gallery .photo{
height: 70px;
margin-right:.8em;
opacity: .5;
}
.profile .popup .gallery .photo:hover{
opacity: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment