Created
June 22, 2017 20:40
-
-
Save anonymous/2bd0710032ffb1297e94f12c7a20a936 to your computer and use it in GitHub Desktop.
null created by dtstanley - https://repl.it/GiQ2/29
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
* { | |
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 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>image carousel solution</title> | |
<script | |
src="https://code.jquery.com/jquery-3.2.1.min.js" | |
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" | |
crossorigin="anonymous"></script> | |
<link href="index.css" rel="stylesheet" type="text/css" /> | |
</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 src="index.js"></script> | |
</body> | |
</html> |
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
//Function to identify thumbnail selected and place in main window | |
function handleThumbnailClicks() { | |
//identifies which thumbnail has been clicked | |
$('.thumbnail').click(function(event) { | |
//Sets a variable to equal the src of the image that was selected | |
var imgSrc = $(event.currentTarget).find('img').attr('src'); | |
//takes the variable data (src) and replaces the hero image with it | |
$('.hero img').attr('src', imgSrc); | |
}) | |
} | |
//this is the code that invokes the function above | |
$(function() { | |
handleThumbnailClicks(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment