Created
March 26, 2013 22:56
-
-
Save damienklinnert/5250073 to your computer and use it in GitHub Desktop.
A CodePen by damienklinnert. transition colors - using hover events and transitions to change the background color of an element - as seen on codeschool.com.
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
<h1>move your mouse over the words</h1> | |
<a href="#light">one</a> | |
<a href="#dark">two</a> |
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
$ -> | |
light = $ '[href="#light"]' | |
dark = $ '[href="#dark"]' | |
bg = $ 'body' | |
light.mouseover (ev) -> | |
bg.css 'background-color', '#FF2151' | |
ev.preventDefault() | |
dark.mouseover (ev) -> | |
bg.css 'background-color', '#FFC629' | |
ev.preventDefault() |
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: #FF2151; | |
-webkit-transition: background-color 1s ease; | |
-moz-transition: background-color 1s ease; | |
-o-transition: background-color 1s ease; | |
transition: background-color 1s ease; | |
} | |
h1 { | |
text-align: center; | |
color: #fff; | |
font-size: 1.25em; | |
font-weight: normal; | |
} | |
a { | |
position: absolute; | |
top: 10%; | |
padding: 1em; | |
font-size: 1.875em; | |
color: #fff; | |
text-decoration: none; | |
} | |
a[href="#light"] { | |
left: 10%; | |
background-color: #FF2151; | |
} | |
a[href="#dark"] { | |
right: 10%; | |
background-color: #FFC629; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment