I have a tooltip box and it is working fine. Now I want to add some fade in fade out once the tool-tip box pops in and out.
<a class="tooltip" title="This is some information for our tooltip." href="#"><img id="graph_one" alt="" src="https://www.onlandscape.co.uk/wp-content/uploads/2013/09/Doug-Chinnery-ICM-Images-4-45x45.jpg" class="graph one"> </a>
Demo : http://jsfiddle.net/squidraj/FHUbA/
How about this?
http://jsfiddle.net/FHUbA/14/
.tooltip:after{
opacity: 0;
-webkit-transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
transition: opacity .25s ease-in-out;
background: #333;
background: rgba(0, 0, 0, .8);
border-radius: 5px;
bottom: 26px;
color: #fff;
content: attr(title);
left: 20%;
padding: 5px 15px;
position: absolute;
z-index: 98;
width: 220px;
}
.tooltip:hover:after {
opacity:1;
}
What about this one:
http://jsfiddle.net/Roobyx/FHUbA/45/
(you can fix the styles afterwards)
HTML:
<a class="has-tooltip" href="#">
<span class="tooltip">This is some information for our tooltip.</span>
<img id="graph_one" class="graph one" src="https://www.onlandscape.co.uk/wp-content/uploads/2013/09/Doug-Chinnery-ICM-Images-4-45x45.jpg" />
</a>
CSS:
a[title].tooltip {
width:45px;
height:90px;
}
.tooltip {
display: inline-block;
position: relative;
}
.has-tooltip {
color: #555;
font-size: 16px;
display: block;
margin: 150px 75px 10px 75px;
padding: 5px 5px;
position: relative;
text-align: center;
width: 200px;
-webkit-transform: translateZ(0); /* webkit flicker fix */
-webkit-font-smoothing: antialiased; /* webkit text rendering fix */
}
.has-tooltip .tooltip {
background: #000;
bottom: 100%;
color: #fff;
display: block;
left: -10px;
margin-bottom: 15px;
border-radius: 5px;
opacity: 0;
padding: 20px;
position: absolute;
visibility: hidden;
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);
}
.has-tooltip .tooltip:before {
bottom: -20px;
content: " ";
display: block;
height: 20px;
left: 0;
position: absolute;
width: 100%;
}
.has-tooltip .tooltip:after {
border-left: solid transparent 10px;
border-right: solid transparent 10px;
border-top: solid #000 10px;
bottom: -10px;
content: " ";
height: 0;
left: 50%;
margin-left: -13px;
position: absolute;
width: 0;
}
.has-tooltip:hover .tooltip {
opacity: 1;
visibility: visible;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-o-transform: translateY(0px);
transform: translateY(0px);
}
Related
I am making this project, but when I resize the window the css goes all over. I do not know how to make it responsive while maintaining the look I want
I have tried switching the units to rem but it still does not work
Here is the CSS:
color: whitesmoke;
}
p{
text-align: center;
font-size:15px;
font-family: 'Source Sans Pro', sans-serif;
}
#space_background{
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
z-index:-1;
min-height: 100%
}
h1{
position: relative;
z-index:1;
text-align: center;
font-size: 3vw;
font-family: 'Source Sans Pro', sans-serif;
}
#planet{
width: 400px;
height: 400px;
z-index: 1;
display: block;
margin: 0 auto;
vertical-align: middle;
}
#send{
display:block;
margin-left: 45vw;
margin-bottom: 2rem;
margin-top: 1rem;
text-align: center;
/* position: relative; */
padding: 1vw 1.3vw;
top: -30px;
max-width: 100%;
font-size: 15px;
font-family: 'Source Sans Pro', sans-serif;
border-radius: 2px;
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
background: rgba(64, 240, 10, 0.795);
color: #fff;
box-shadow: 0px 0px 0px rgba(255, 255, 255, 0.1);
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
transition: all 0.2s ease;
}
#send:hover{
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
#divSend{
text-align: center;
}
#next{
display:block;
margin-left: 46.25vw;
margin-top: 5rem;
margin-bottom: 5px;
text-align: center;
position: relative;
padding: 0.5vw 0.8vw;
top: -30px;
max-width: 100%;
font-size: 15px;
font-family: 'Source Sans Pro', sans-serif;
border-radius: 2px;
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
background: rgba(102, 102, 102, 0.795);
color: #fff;
box-shadow: 0px 0px 0px rgba(255, 255, 255, 0.1);
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
transition: all 0.2s ease;
}
#next:hover{
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
#nextDiv{
text-align: center;
}
#atmo{
display:block;
float: left;
margin-left: 9.5vw;
margin-right: 1vw;
margin-bottom: 20px;
text-align: center;
position: relative;
padding: 0.5vw 0.8vw;
top: -30px;
max-width: 100%;
font-size: 15px;
font-family: 'Source Sans Pro', sans-serif;
border-radius: 2px;
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
background: rgba(102, 102, 102, 0.795);
color: #fff;
box-shadow: 0px 0px 0px rgba(255, 255, 255, 0.1);
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
transition: all 0.2s ease;
}
#atmo:hover{
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
#rot{
float: right;
margin-right: 1vw;
float: left;
display:block;
margin-bottom: 20px;
text-align: center;
position: relative;
padding: 0.5vw 0.8vw;
top: -30px;
max-width: 100%;
font-size: 15px;
font-family: 'Source Sans Pro', sans-serif;
border-radius: 2px;
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
background: rgba(102, 102, 102, 0.795);
color: #fff;
box-shadow: 0px 0px 0px rgba(255, 255, 255, 0.1);
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
transition: all 0.2s ease;
}
#rot:hover{
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
#core{
display:block;
float: left;
margin-right: 31vw;
float: left;
margin-bottom: 20px;
text-align: center;
position: relative;
padding: 0.5vw 0.8vw;
top: -30px;
max-width: 100%;
font-size: 15px;
font-family: 'Source Sans Pro', sans-serif;
border-radius: 2px;
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
background: rgba(102, 102, 102, 0.795);
color: #fff;
box-shadow: 0px 0px 0px rgba(255, 255, 255, 0.1);
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
transition: all 0.2s ease;
}
#core:hover{
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
#goldi{
display:block;
float: right;
float: left;
margin-right: 1rem;
margin-bottom: 20px;
text-align: center;
position: relative;
padding: 0.5vw 0.8vw;
top: -30px;
max-width: 100%;
font-size: 15px;
font-family: 'Source Sans Pro', sans-serif;
border-radius: 2px;
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
background: rgba(102, 102, 102, 0.795);
color: #fff;
box-shadow: 0px 0px 0px rgba(255, 255, 255, 0.1);
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
transition: all 0.2s ease;
}
#goldi:hover{
-webkit-transform: scale(1.1);
transform: scale(1.1);+
}
#stable{
display:block;
float: left;
float: left;
margin-right: 1rem;
margin-bottom: 20px;
text-align: center;
position: relative;
padding: 0.5vw 0.8vw;
top: -30px;
max-width: 100%;
font-size: 15px;
font-family: 'Source Sans Pro', sans-serif;
border-radius: 2px;
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
background: rgba(102, 102, 102, 0.795);
color: #fff;
box-shadow: 0px 0px 0px rgba(255, 255, 255, 0.1);
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
transition: all 0.2s ease;
}
#stable:hover{
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
#water{
display:block;
margin-bottom: 20px;
text-align: center;
position: relative;
padding: 0.5vw 0.8vw;
top: -30px;
max-width: 100%;
font-size: 15px;
font-family: 'Source Sans Pro', sans-serif;
border-radius: 2px;
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
background: rgba(102, 102, 102, 0.795);
color: #fff;
box-shadow: 0px 0px 0px rgba(255, 255, 255, 0.1);
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
transition: all 0.2s ease;
}
#water:hover{
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
#firstThree{
margin-left: 9.5vw;
}
#lastThree{
margin-left: 66vw;
margin-top: -18px
}
HTML:
<html>
<head>
<meta charset="UTF-8">
<title>Vitae Vinctum</title>
<link rel="stylesheet" type="text/css" href="start_style.css">
<link href="https://fonts.googleapis.com/css?family=Abel|Source+Code+Pro&display=swap" rel="stylesheet">
<!-- <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> -->
</head>
<body>
<video playsinline="playsinline" autoplay muted loop id="space_background">
<source src="imgs/Space_Background.mp4" type="video/mp4">
<img src="imgs/background.jpg" title="Your browser does not support video">
</video>
<h1>The Search for Life Begins...</h1>
<div>
<img id="planet" src="imgs/planet.png">
</div>
<div id="nextDiv">
<button id="next">Next Planet</button>
</div>
<div id="divSend">
<button id="send">Send Expedition</button>
</div>
<div>
<button id="atmo">Atmospheric Test</button>
<button id="rot">Send Expedition</button>
</div>
<div>
<button id="core">Send Expedition</button>
<button id="goldi">Send Expedition</button>
</div>
<div>
<button id="stable">Send Expedition</button>
<button id="water">Send Expedition</button>
</div>
<div id="testResponse">
<p></p>
<p id="atmoText">test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
</div>
<script src="index.js"></script>
</body>
</html>
It works at full resolution but as soon as the window resizes, it goes wack
You can use both width and max-width properties for one css object:
#planet {
width: 400px;
height: 400px;
max-width: 100%;
z-index: 1;
display: block;
margin: 0 auto;
vertical-align: middle;
}
To make your objects responsive, you should use media queries.
#media screen and (max-width: 400px) {
#planet {width: 100%}
}
#media screen and (min-width: 401px) and (max-width: 700px) {
#planet {width: 75%;}
}
#planet {width: 50%;}
I am using a hover effect from hover.css. It works well in every browser except in Opera.
It only seems to work in Opera when I remove the properties:
-webkit-transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
But then, it doesn't work in Firefox.
I have also created this JSFiddle:
https://jsfiddle.net/ta4sju8n/20/
But it seems to work fine there...
HTML:
<ul>
<li>Hover me</li>
<li>Hover me</li>
<li>Hover me</li>
</ul>
SCSS:
body {
background-color: black;
color: white;
}
ul {
list-style: none;
li {
padding: 10px;
a {
display: inline-block;
vertical-align: middle;
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
position: relative;
overflow: hidden;
color: white;
margin-top: 10px;
margin-bottom: 10px;
padding-bottom: 8px;
text-decoration: none;
/* Border bottom animation */
&:after {
content: "";
position: absolute;
z-index: -1;
left: 0;
right: 100%;
bottom: 0;
background: white;
height: 1px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
&:hover:after {
right: 0;
}
}
}
}
Anybody can help me out here?
Update:
Issue fixed. I removed perspective(1px) and now the property transform looks like so:
-webkit-transform: translateZ(0);
transform: translateZ(0);
Final Code:
HTML:
<ul>
<li>Hover me</li>
<li>Hover me</li>
<li>Hover me</li>
</ul>
SCSS:
body {
background-color: black;
color: white;
}
ul {
list-style: none;
li {
padding: 10px;
a {
display: inline-block;
vertical-align: middle;
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-transform: translateZ(0);
transform: translateZ(0);
position: relative;
overflow: hidden;
color: white;
margin-top: 10px;
margin-bottom: 10px;
padding-bottom: 8px;
text-decoration: none;
/* Border bottom animation */
&:after {
content: "";
position: absolute;
z-index: -1;
left: 0;
right: 100%;
bottom: 0;
background: white;
height: 1px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
&:hover:after {
right: 0;
}
}
}
}
I personally can't recreate the problem, but a user is seeing blurring on the text within tooltips. She's running an up-to-date version of Chrome on a modern Windows machine. She says it's pretty hard to even make out what the text says.
/* The question mark that the user clicks on */
.tooltip_wrapper {
font-size: 14px;
display: inline-block;
margin-left: 10px;
padding: 0 10px;
background: #ececec;
color: #555;
cursor: help;
font-family: "Gill Sans", Impact, sans-serif;
position: relative;
text-align: center;
-webkit-transform: translateZ(0); /* WebKit flicker fix */
-webkit-font-smoothing: antialiased; /* WebKit text rendering fix */
z-index: 900;
}
.tooltip_wrapper .tooltip {
background: #1496bb;
bottom: 100%;
color: #fff;
display: block;
left: -25px;
margin-bottom: 15px;
opacity: 0; /* This hides the box when not hovering */
padding: 20px;
pointer-events: none;
position: absolute;
width: 400px;
-webkit-transform: translate(10px);
-moz-transform: translate(10px);
-ms-transform: translate(10px);
-o-transform: translate(10px);
transform: translate(10px);
/* These used to be all translateY */
-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 */
.tooltip_wrapper .tooltip:before {
bottom: -20px;
content: " ";
display: block;
height: 20px;
left: 0;
position: absolute;
width: 100%;
}
/* CSS Triangles - see Trevor's post */
.tooltip_wrapper .tooltip:after {
border-left: solid transparent 10px;
border-right: solid transparent 10px;
border-top: solid #1496bb 10px;
bottom: -10px;
content: " ";
height: 0;
right: 88%;
margin-left: -13px;
position: absolute;
width: 0;
}
.tooltip_wrapper:hover .tooltip {
opacity: 1;
pointer-events: auto;
-webkit-transform: translate(0px);
-moz-transform: translate(0px);
-ms-transform: translate(0px);
-o-transform: translate(0px);
transform: translate(0px);
/* These used to be all translateY */
}
/* Internet Explorer can just show/hide with no transition */
.lte8 .tooltip_wrapper .tooltip {
display: none;
}
.lte8 .tooltip_wrapper:hover .tooltip {
display: block;
}
<h1>
Some header to create space
</h1>
<div class='tooltip_wrapper'>?<div class='tooltip'>This is the tooltip text</div></div>
I've set up a JSFiddle on that site too, https://jsfiddle.net/rsnbtph7/#&togetherjs=xDN35iPAvV.
Where should I tweak the code so these users aren't disadvantaged?!
CalvT got it in one - I changed the font to Arial and the problem is now gone.
Yes Changing font-family is really works, just paste this line in your css and you will be done.
.tooltip {
font-family: Arial,sans-serif !important;
}
I have this code: https://jsfiddle.net/e0u4sow1/6/
It works, I added a arrow beneath the text when you hover over the image. I want that arrow to slide in from the left to the center with a slow end and when you move your mouse away to slide right with a slow start. I spend 2 hours now trying many things to get this to work, but I give up. Can someone help me with this? also maybe a small explanation as to what part in the code makes the arrow slide in and out? I removed all code with arroweffect relations, so it's just the original effect with the arrow added
.media {
display: inline-block;
position: relative;
vertical-align: top;
}
.media__image {
display: block;
}
.media__body {
background: rgba(41, 128, 185, 0.7);
bottom: 0;
color: white;
font-size: 1em;
left: 0;
opacity: 0;
overflow: hidden;
padding: 3.75em 3em;
position: absolute;
text-align: center;
top: 0;
right: 0;
-webkit-transition: 0.6s;
transition: 0.6s;
}
.media__body:hover {
opacity: 1;
}
.media__body:after,
.media__body:before {
border: 1px solid rgba(255, 255, 255, 0.7);
bottom: 1em;
content: '';
left: 1em;
opacity: 0;
position: absolute;
right: 1em;
top: 1em;
-webkit-transform: scale(1.5);
-ms-transform: scale(1.5);
transform: scale(1.5);
-webkit-transition: 0.6s 0.2s;
transition: 0.6s 0.2s;
}
.media__body:before {
border-bottom: none;
border-top: none;
left: 2em;
right: 2em;
}
.media__body:after {
border-left: none;
border-right: none;
bottom: 2em;
top: 2em;
}
.media__body:hover:after,
.media__body:hover:before {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
.media__body h2 {
margin-top: 0;
}
.media__body p {
margin-bottom: 1.5em;
}
.arr {
display: inline-block;
padding: 1.2em;
box-shadow: 8px 8px 0 2px #FFF inset;
transform: rotate(135deg);
}
<h1>MR Cube</h1>
<div class="media">
<a href="http://www.google.nl/">
<img alt="" class="media__image" src="http://www.webwinkelsucces.nl/wp-content/uploads/2015/05/1112625-les-outils-de-test-et-d-integration-continue-open-source.jpg" />
<div class="media__body">
<h1>Lees meer</h1>
<div class="arr"></div>
</div>
</a>
As you didn't post your try to make the animation, it's hard to explain what you did wrong.
I made the animation in the following example adding translate on the arrow and removing it on hover. The transition decalration makes the animation between both states.
.media {
display: inline-block;
position: relative;
vertical-align: top;
}
.media__image {
display: block;
}
.media__body {
background: rgba(41, 128, 185, 0.7);
bottom: 0;
color: white;
font-size: 1em;
left: 0;
opacity: 0;
overflow: hidden;
padding: 3.75em 3em;
position: absolute;
text-align: center;
top: 0;
right: 0;
-webkit-transition: 0.6s;
transition: 0.6s;
}
.media__body:hover {
opacity: 1;
}
.media__body:after,
.media__body:before {
border: 1px solid rgba(255, 255, 255, 0.7);
bottom: 1em;
content: '';
left: 1em;
opacity: 0;
position: absolute;
right: 1em;
top: 1em;
-webkit-transform: scale(1.5);
-ms-transform: scale(1.5);
transform: scale(1.5);
-webkit-transition: 0.6s 0.2s;
transition: 0.6s 0.2s;
}
.media__body:before {
border-bottom: none;
border-top: none;
left: 2em;
right: 2em;
}
.media__body:after {
border-left: none;
border-right: none;
bottom: 2em;
top: 2em;
}
.media__body:hover:after,
.media__body:hover:before {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
.media__body h2 {
margin-top: 0;
}
.media__body p {
margin-bottom: 1.5em;
}
.arr {
display: inline-block;
padding: 1.2em;
box-shadow: 8px 8px 0 2px #FFF inset;
transform: translateX(250px) rotate(135deg);
transition: transform .8s ease-in;
}
.media__body:hover .arr {
transform: translateX(0) rotate(135deg);
transition-timing-function: ease-out;
}
<div class="media">
<a href="http://www.google.nl/">
<img alt="" class="media__image" src="http://www.webwinkelsucces.nl/wp-content/uploads/2015/05/1112625-les-outils-de-test-et-d-integration-continue-open-source.jpg" />
<div class="media__body">
<h1>Lees meer</h1>
<div class="arr"></div>
</div>
</a>
Note that you will need to add the vendor prefixes to the transition and transform properties for browser support (see canIuse for 2D transform and transitions)
I would also suggest you read up on MDN about transforms and transitions.
I'm helping a friend out with a website and she has pretty specific type of button in mind:
"I would like the buttons to be hexagon shape, with a photo in the middle and actually depress as clicked before moving to the portfolio page."
I've managed to create a rounded square that depresses using CSS and HTML pretty easily, however I can't work out a hexagon. Anyone offer some help here?
Fiddle
HTML:
<a href="#" class="button">
<span>
<p> Jorgie</p></span>
</a>
CSS:
.button {
display: inline-block;
margin: 30px;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
-webkit-box-shadow: 0 8px 0 #463E3F, 0 15px 20px rgba(0, 0, 0, .35);
-moz-box-shadow: 0 8px 0 #463E3F, 0 15px 20px rgba(0, 0, 0, .35);
box-shadow: 0 8px 0 #463E3F, 0 15px 20px rgba(0, 0, 0, .35);
-webkit-transition: -webkit-box-shadow .1s ease-in-out;
-moz-transition: -moz-box-shadow .1s ease-in-out;
-o-transition: -o-box-shadow .1s ease-in-out;
transition: box-shadow .1s ease-in-out;
font-size: 20px;
color: #fff;
}
.button span {
display: inline-block;
background-color: black;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
-webkit-box-shadow: inset 0 -1px 1px rgba(255, 255, 255, .15);
-moz-box-shadow: inset 0 -1px 1px rgba(255, 255, 255, .15);
box-shadow: inset 0 -1px 1px rgba(255, 255, 255, .15);
font-family: 'Pacifico', Arial, sans-serif;
line-height: 1;
text-shadow: 0 -1px 1px rgba(175, 49, 95, .7);
-webkit-transition: background-color .2s ease-in-out, -webkit-transform .1s ease-in- out;
-moz-transition: background-color .2s ease-in-out, -moz-transform .1s ease-in-out;
-o-transition: background-color .2s ease-in-out, -o-transform .1s ease-in-out;
transition: background-color .2s ease-in-out, transform .1s ease-in-out;
}
.button:hover span {
background-image:url(jorgie.jpg);
background-repeat:no-repeat;
background-position:center;
text-shadow: 0 -1px 1px rgba(175, 49, 95, .9), 0 0 5px rgba(255, 255, 255, .8);
}
.button:active, .button:focus {
-webkit-box-shadow: 0 8px 0 #463E3F, 0 12px 10px rgba(0, 0, 0, .3);
-moz-box-shadow: 0 8px 0 #463E3F, 0 12px 10px rgba(0, 0, 0, .3);
box-shadow: 0 8px 0 #463E3F, 0 12px 10px rgba(0, 0, 0, .3);
}
.button:active span {
-webkit-transform: translate(0, 4px);
-moz-transform: translate(0, 4px);
-o-transform: translate(0, 4px);
transform: translate(0, 4px);
}
Here is a hexagon shaped button adapted from the soluion described in this question : Button with pointed edges and shadow :
The hexagon is made with skewed pseudo elements the shadow is made with box-shadows and the transition on the click event is made with CSS:
DEMO
HTML :
<div class="button top">
<div class="button bottom"></div>
</div>
CSS :
.top{
position:relative;
top:0;
margin-left:150px;
width: 45px;
height: 60px;
-webkit-transition: top .1s;
-ms-transition: top .1s;
transition: top .1s;
}
.button:before, .button:after{
position: absolute;
width:70%; height:50%;
content: "";
z-index:-1;
}
.top:before {
left:0; top:0;
-webkit-transform:skewX(-20deg);
-ms-transform:skewX(-20deg);
transform:skewX(-20deg);
background: #469BF9;
box-shadow: -5px 10px 0px -5px #104f96;
z-index:-2;
}
.top:after {
right:0; top:0;
-webkit-transform:skewX(20deg);
-ms-transform:skewX(20deg);
transform:skewX(20deg);
background: #469BF9;
box-shadow: 5px 10px 0px -5px #104f96;
z-index:-2;
}
.bottom:before{
left:0; top:50%; transitions.
-webkit-transform:skewX(20deg);
-ms-transform:skewX(20deg);
transform:skewX(20deg);
background: #1E80F7;
box-shadow: -4px 5px 0px 0px #104f96;
}
.bottom:after{
right:0; top:50%;
-webkit-transform:skewX(-20deg);
-ms-transform:skewX(-20deg);
transform:skewX(-20deg);
background: #1E80F7;
box-shadow: 4px 5px 0px 0px #104f96;
}
.button:after, .button:before{
-webkit-transition: box-shadow .1s;
-ms-transition: box-shadow .1s;
transition: box-shadow .1s;
}
.top:active{
top:5px;
}
.button:active:after, .button:active:before, .button:active .button:before, .button:active .button:after {
box-shadow: 0px 0px 0px 0px #104f96;
}
To my knowledge,a hexagon with full image requires multiple divs as follows
JSfiddle Demo
HMTL
<div class="hexagon">
<div class="hexagon-in1">
<div class="hexagon-in2">
</div>
</div>
</div>
CSS
.hexagon {
-webkit-transform: rotate(120deg);
-moz-transform: rotate(120deg);
-o-transform: rotate(120deg);
transform: rotate(120deg);
cursor: pointer;
width: 400px;
height: 200px;
margin: 25px;
visibility: hidden;
overflow: hidden;
}
.hexagon-in1 {
width: 100%;
height: 100%;
-webkit-transform: rotate(-60deg);
-moz-transform: rotate(-60deg);
-o-transform: rotate(-60deg);
transform: rotate(-60deg);
overflow: hidden;
}
.hexagon-in2 {
width: 100%;
height: 100%;
background-repeat: no-repeat;
background-position: 50%;
background-image: url(http://placekitten.com/241/241);
visibility: visible;
-webkit-transform: rotate(-60deg);
-moz-transform: rotate(-60deg);
-o-transform: rotate(-60deg);
transform: rotate(-60deg);
}
.hexagon-in2 a {
display: block;
}
Actual 'button down' effects might a little harder.
Frankly, I'd be looking to use an actual image here..rather than unsemantic 'styling' divs for this button.
For hexagon button, here's a FIDDLE
<div id="hexagon"></div>
#hexagon {
width: 100px;
height: 55px;
background: red;
position: relative;
}
#hexagon:before {
content: "";
position: absolute;
top: -25px;
left: 0;
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 25px solid red;
}
#hexagon:after {
content: "";
position: absolute;
bottom: -25px;
left: 0;
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 25px solid red;
}