2

I have an image that I want to expand once clicked on. I have it with the code looking like this:

.siteFeatures { display: flex; flex-wrap: wrap; } .siteFeatures div { display: inline-block; } .feature { margin: 5px; } .siteFeatures input[type=checkbox] { display: none; } .siteFeatures img { height: 10rem; transition: transform 0.25s ease; transform-origin: top left; cursor: zoom-in; } .siteFeatures input[type=checkbox]:checked ~ label > img { transform: scale(3); transform-origin: top left; cursor: zoom-out; }
<div class="siteFeatures"> <div class="feature teamRandomizerFeature"> <p>Randomize Teams!</p> <input type="checkbox" id="zoomCheckRandomizer"> <label for="zoomCheckRandomizer"> <img src="https://www.pokemondatabase.net/images/general/teamRandomizer.png"> </label> </div> <div class="feature typeEvaluator"> <p>Lookup Type Combinations!</p> <input type="checkbox" id="zoomCheckTypingEvaluator"> <label for="zoomCheckTypingEvaluator"> <img src="https://www.pokemondatabase.net/images/general/typingEvaluator.png"> </label> </div> <div class="feature eggGroupEvaluator"> <p>Lookup Egg Group Combinations!</p> <input type="checkbox" id="zoomCheckEggGroupEvaluator"> <label for="zoomCheckEggGroupEvaluator"> <img src="https://www.pokemondatabase.net/images/general/eggGroupEvaluator.png"> </label> </div> </div>

As you can see with the example, the image goes past the window border. I need the image to stay within that border, though still able to expand until it's width is 100%.

2

1 Answer 1

1

Added transform-origin: top left; to couple of classes .siteFeatures img { and .siteFeatures input[type=checkbox]:checked ~ label > img {

.siteFeatures input[type=checkbox] { display: none; } .siteFeatures img { transform-origin: top left; height: 10rem; transition: transform 0.25s ease; cursor: zoom-in; } .siteFeatures input[type=checkbox]:checked ~ label > img { transform: scale(3); transform-origin: top left; cursor: zoom-out; }
<div class="siteFeatures"> <div class="feature teamRandomizerFeature"> <p>Randomize Teams!</p> <input type="checkbox" id="zoomCheckRandomizer"> <label for="zoomCheckRandomizer"> <img src="https://www.pokemondatabase.net/images/general/teamRandomizer.png"> </label> </div> </div>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.