Created
December 2, 2012 18:32
-
-
Save henrahmagix/4190346 to your computer and use it in GitHub Desktop.
Indented button with increased hit area.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-color: #B9B79E; | |
color: #2C241D; | |
font-family: "PT Sans", Arial; | |
font-size: 12px; | |
font-weight: normal; | |
} | |
code { | |
background-color: #EDEDE7; | |
color: #2C241D; | |
padding: 0 0.5em; | |
} | |
a { | |
color: inherit; | |
text-decoration: inherit; | |
} | |
.title, .subtitle, .button { | |
font-family: "Arvo"; | |
text-align: center; | |
} | |
article { | |
color: #EDEDE7; | |
margin: 2% 0; | |
text-align: justify; | |
width: 38%; | |
} | |
p { | |
background-color: #593723; | |
border: 2px solid #EDEDE7; | |
-moz-box-shadow: 4px 4px 4px 2px rgba(0, 0, 0, 0.3); | |
-webkit-box-shadow: 4px 4px 4px 2px rgba(0, 0, 0, 0.3); | |
box-shadow: 4px 4px 4px 2px rgba(0, 0, 0, 0.3); | |
padding: 2%; | |
} | |
.left { | |
float: left; | |
margin-left: 5%; | |
} | |
.right { | |
float: right; | |
margin-right: 5%; | |
} | |
.button { | |
cursor: pointer; | |
font-size: 16px; | |
line-height: 16px; | |
margin: 0 auto 30px; | |
} | |
.side-by-side { | |
margin: 0 auto; | |
position: relative; | |
text-align: center; | |
} | |
.info { | |
color: #2C241D; | |
} | |
.clearfix:after { | |
content: "."; | |
display: block; | |
clear: both; | |
visibility: hidden; | |
line-height: 0; | |
height: 0; | |
} | |
.clearfix { | |
display: inline-block; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Quick Jump Link</title> | |
<link href="http://fonts.googleapis.com/css?family=Arvo" rel="stylesheet" type="text/css"> | |
<link href="http://fonts.googleapis.com/css?family=PT+Sans" rel="stylesheet" type="text/css"> | |
<link rel="stylesheet" type="text/css" href="index.css"> | |
<link rel="stylesheet" type="text/css" href="button.css"> | |
</head> | |
<body> | |
<h1 class="title">Indented Button</h1> | |
<h2 class="subtitle">A button using <code>:before</code> and <code>:after</code> to increase hit area, thus avoiding a jumpy effect.</h2> | |
<section class="clearfix"> | |
<article class="left"> | |
<p>Slowly move your cursor onto the button from above and notice how it jumps. This is because the button is moved using <code>top</code> when hovered on, which means the button's hit area is no longer under the cursor.</p> | |
<a class="button jumpy" href="#">Jumpy</a> | |
<a class="button animated" href="#">I'm animated!</a> | |
</article> | |
<article class="right"> | |
<p>Do the same to this button and your cursor will hit a transparent <code>:before</code> element, which is deemed a child element of the button, thus increasing its hit area.</p> | |
<div class="side-by-side"> | |
<a class="button not-jumpy" href="#">Not jumpy</a> | |
<a class="button not-jumpy show-hit-area" href="#">Show effect</a> | |
<span class="info"><strong>The <code>:before</code> element is shown in black.</strong></span> | |
</div> | |
</article> | |
</section> | |
<h2 class="subtitle">Try clicking them too!</h2> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment