You can use a lightbox to do it.
There is a simple example in this link:
http://lokeshdhakar.com/projects/lightbox2/
Answer from Jack on Stack OverflowYou can use a lightbox to do it.
There is a simple example in this link:
http://lokeshdhakar.com/projects/lightbox2/
You can use a lightbox.
It's really simple to use. Include the script tags and CSS stylesheets in your HTML file, and then simply use:
<a class="example-image-link" href="images/image-1.jpg" data-lightbox="example-1"><img class="example-image" src="images/thumb-1.jpg" alt="Girl looking out people on beach"></a>
Videos
The span elements should be completely removed and its classes placed on the image elements themselves.
Also, you have a nested section element that isn't doing anything for you.
Lastly, do not use HTML heading elements (<h1>...<h6>) because of the way they style the text. Formatting is the job of CSS. Instead of headings, it is more appropriate to surround each image and its accompanying text with figure and figcaption elements.
img {
width:200px;
border:1px solid black; /* This is only added for testing purposes*/
}
.thumbnail:hover {
width: 500px;
height:auto;
position:relative;
/* push image to the right by 1/2 the screen width and 1/2 the image width */
margin-left:calc(50% - 250px);
}
<section id="main">
<div class="inner">
<div class="box alt">
<div class="row 50% uniform">
<div class="4u">
<figure>
<img src="https://pbs.twimg.com/profile_images/562466745340817408/_nIu8KHX.jpeg" alt="" class="thumbnail">
<figcaption>Marble</figcaption>
</figure>
</div>
<div class="4u">
<figure>
<img src="http://www.critterbabies.com/wp-content/gallery/kittens/cats-animals-kittens-background-us.jpg" alt="" class="thumbnail">
<figcaption>Marble</figcaption>
</figure>
</div>
<div class="4u">
<figure>
<img src="http://www.warrenphotographic.co.uk/photography/bigs/08482-Fluffy-ginger-female-kitten.jpg" alt="" class="thumbnail">
<figcaption>Marble</figcaption>
</figure>
</div>
</div>
</div>
</div>
</section>
I've taken Scott Marcus' answer and adapted to click, which was your original request.
The main diffence is the addition of a tags targeting elements on the page and using :target in the css.
img {
width:200px;
border:1px solid black; /* This is only added for testing purposes*/
}
.thumbnail:target {
width: 500px;
height:auto;
position:relative;
/* push image to the right by 1/2 the screen width and 1/2 the image width */
margin-left:calc(50% - 250px);
}
<section id="main">
<div class="inner">
<div class="box alt">
<div class="row 50% uniform">
<div class="4u">
<figure>
<a href="#image1">
<img src="https://pbs.twimg.com/profile_images/562466745340817408/_nIu8KHX.jpeg" alt="" class="thumbnail" id="image1">
</a>
<figcaption>Marble</figcaption>
</figure>
</div>
<div class="4u">
<figure>
<a href="#image2">
<img src="http://www.critterbabies.com/wp-content/gallery/kittens/cats-animals-kittens-background-us.jpg" alt="" class="thumbnail" id="image2">
</a>
<figcaption>Marble</figcaption>
</figure>
</div>
<div class="4u">
<figure>
<a href="#image3">
<img src="http://www.warrenphotographic.co.uk/photography/bigs/08482-Fluffy-ginger-female-kitten.jpg" alt="" class="thumbnail" id="image3">
</a>
<figcaption>Marble</figcaption>
</figure>
</div>
</div>
</div>
</div>
</section>
Seems that you are missing some CSS rules.
Let's have a look on this line:
popup.classList.toggle("show");
The toggle function here will add a class show class if the element popup does not have one, otherwise remove it.
That means the item with class popuptext should not display by default and unless the show class is added.
Therefore, you should define 2 CSS styles like the following:
.popuptext.show {
display: inline-block; // show element when you have the class name 'show'
}
.popuptext {
display: none; // hide by default
}
Here is a working example: https://jsfiddle.net/3bmqdcsg/
Without seeing your CSS code for .show, I can't really determine what went wrong, but adding some CSS code for .show and .popuptext, everything works!
EDIT: I have also added a simple animation code to animate a "popup"
.show {
display: block!important;
/* The bottom is for animation when the popup gets shown */
animation: popup .2s 1;
}
@keyframes popup {
from { transform: scale(0); }
to { transform: scale(1); }
}
.popuptext {
display: none;
}
<nav>
Navigation Bar
<ul>
<li>
<div class="popup" onclick="myFunction()">
Myself
<span class="popuptext" id="myPopup">My description</span>
<img src="/images/picture.jpg" alt="My picture" />
</div>
<script>
function myFunction() {
var popup = document.getElementById("myPopup");
popup.classList.toggle("show");
}
</script>
</li>
<li>Contact</li>
<li>Other</li>
</ul>
</nav>