Simple mouseover on a text, changing its color and font size.
Last active
August 29, 2015 13:56
-
-
Save andipollok/8844467 to your computer and use it in GitHub Desktop.
Text Hover Effect
This file contains hidden or 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
| <!DOCTYPE html> | |
| <meta charset="utf-8"> | |
| <title></title> | |
| <script src="http://d3js.org/d3.v3.min.js"></script> | |
| <script src="http://code.jquery.com/jquery-latest.min.js"></script> | |
| <style> | |
| text { | |
| font-family: Helvetica, Arial, sans-serif; | |
| cursor: pointer; | |
| } | |
| </style> | |
| <body> | |
| <script> | |
| var width = 960, | |
| height = 500; | |
| var svg = d3.select('body').append('svg') | |
| .attr('width', width) | |
| .attr('height', height); | |
| svg.append('text') | |
| .text('Touch me') | |
| .attr('x', width/2) | |
| .attr('y', height/2) | |
| .attr('font-size', 20) | |
| .attr('fill', '#333') | |
| .style('text-anchor', 'middle') | |
| .on('mouseover', function(d,i) { | |
| d3.select(this).transition() | |
| .ease('cubic-out') | |
| .duration('200') | |
| .attr('font-size', 32) | |
| .attr('fill', 'springgreen'); | |
| }) | |
| .on('mouseout', function(d,i) { | |
| d3.select(this).transition() | |
| .ease('cubic-out') | |
| .duration('200') | |
| .attr('font-size', 20) | |
| .attr('fill', '#333'); | |
| }); | |
| </script> | |
| </body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment