Last active
February 21, 2017 19:33
-
-
Save yh2n/4bb0a84dafeb5065e1ef3fe44b342153 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/tahasug
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> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
* { | |
box-sizing: border-box; | |
} | |
main { | |
padding: 30px; | |
min-width: 250px; | |
} | |
.hero { | |
height: 200px; | |
margin-bottom: 20px; | |
} | |
.hero img { | |
height: 100% | |
} | |
.thumbnail { | |
display: inline-block; | |
cursor: pointer; | |
height: 60px; | |
} | |
a.thumbnail:hover { | |
box-shadow: 5px 5px 5px gray; | |
} | |
.thumbnail img { | |
max-height: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<main> | |
<h1>Image Carousel</h1> | |
<div class="hero"> | |
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/cat1.jpg" alt="" /> | |
</div> | |
<div class="thumbnails"> | |
<a class="thumbnail"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/cat1.jpg" alt="" /></a> | |
<a class="thumbnail"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/cat2.jpg" alt="" /></a> | |
<a class="thumbnail"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/cat3.jpg" alt="" /></a> | |
<a class="thumbnail"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/cat4.jpg" alt="" /></a> | |
</div> | |
<script src="https://code.jquery.com/jquery-3.1.0.js"></script> | |
</main> | |
<script id="jsbin-javascript"> | |
// your code here | |
function displayImg () { | |
$(".thumbnail").click(function(event) { | |
var selection= $(event.currentTarget).find("img").attr("src"); | |
$(".hero img").attr("src", selection); | |
}) | |
} | |
$(function() { | |
displayImg(); | |
}); | |
</script> | |
<script id="jsbin-source-css" type="text/css">* { | |
box-sizing: border-box; | |
} | |
main { | |
padding: 30px; | |
min-width: 250px; | |
} | |
.hero { | |
height: 200px; | |
margin-bottom: 20px; | |
} | |
.hero img { | |
height: 100% | |
} | |
.thumbnail { | |
display: inline-block; | |
cursor: pointer; | |
height: 60px; | |
} | |
a.thumbnail:hover { | |
box-shadow: 5px 5px 5px gray; | |
} | |
.thumbnail img { | |
max-height: 100%; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">// your code here | |
function displayImg () { | |
$(".thumbnail").click(function(event) { | |
var selection= $(event.currentTarget).find("img").attr("src"); | |
$(".hero img").attr("src", selection); | |
}) | |
} | |
$(function() { | |
displayImg(); | |
}); | |
</script></body> | |
</html> |
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
* { | |
box-sizing: border-box; | |
} | |
main { | |
padding: 30px; | |
min-width: 250px; | |
} | |
.hero { | |
height: 200px; | |
margin-bottom: 20px; | |
} | |
.hero img { | |
height: 100% | |
} | |
.thumbnail { | |
display: inline-block; | |
cursor: pointer; | |
height: 60px; | |
} | |
a.thumbnail:hover { | |
box-shadow: 5px 5px 5px gray; | |
} | |
.thumbnail img { | |
max-height: 100%; | |
} |
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
// your code here | |
function displayImg () { | |
$(".thumbnail").click(function(event) { | |
var selection= $(event.currentTarget).find("img").attr("src"); | |
$(".hero img").attr("src", selection); | |
}) | |
} | |
$(function() { | |
displayImg(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment