Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Making an image full-screen when clicked on.

Community Beginner ,
Aug 15, 2015 Aug 15, 2015

I wish to make my images full screen available,so when you click on it the image enlarges and it comes to the center possibly.

When you are finished looking on the picture you can close it by pressing the "X".

How is this possible?

Thank you

TOPICS
How to
24.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 15, 2015 Aug 15, 2015

Fullscreen example below - simple bit of jQuery. I've used the same sized image for the thumbnail and large image for the example but to save on bandwidth reduce the size of the thumbnail images.

<!DOCTYPE>

<html>

<head>

<meta ="charset=UTF-8" />

<title>Full Screen Gallery</title>

<style>

html {

height: 100%;

}

body {

font-family: helvetica, sans-serif;

height: 100%;

margin: 100px 0;

}

.photo-overlay {

    height: 100%;

    width: 100%;

    position: absolute;

    top: 0;

    left: 0;

    background-color:#9F3;

    b

...
Translate
Community Expert ,
Aug 15, 2015 Aug 15, 2015

This is done with JavaScript or jQuery Modal Windows -- sometimes called Lightboxes.  See links below.

fancyBox - Fancy jQuery Lightbox Alternative

Bootstrap components: modal window

http://www.w3schools.com/bootstrap/bootstrap_modal.asp

Nancy O.

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 15, 2015 Aug 15, 2015

I should have added to my reply that you must use 2 sets of images in your modal window.  A thumbnail size image linked to the full size image.

Nancy O.

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 15, 2015 Aug 15, 2015

Images stretched beyond their native size get pretty raggedy.

Are you sure that's what you want?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 15, 2015 Aug 15, 2015

Fullscreen example below - simple bit of jQuery. I've used the same sized image for the thumbnail and large image for the example but to save on bandwidth reduce the size of the thumbnail images.

<!DOCTYPE>

<html>

<head>

<meta ="charset=UTF-8" />

<title>Full Screen Gallery</title>

<style>

html {

height: 100%;

}

body {

font-family: helvetica, sans-serif;

height: 100%;

margin: 100px 0;

}

.photo-overlay {

    height: 100%;

    width: 100%;

    position: absolute;

    top: 0;

    left: 0;

    background-color:#9F3;

    background-size: cover;

    }

    .close-photo-overlay {

    font-size: 30px;

    position: absolute;

    right: 50px;

    top: 50px;

    color: #fff;

    z-index: 2;

    padding: 6px 9px;

    border: 1px solid #fff;

    }

.imgBox {

    width: 20%;

    margin: 0 auto;

}

img {

    max-width: 100%;

    height: auto;

    padding: 0 0 15px 0;

}

</style>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">

<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>

<script>

$(document).ready(function() {

$('.photo-overlay').hide();

$('.thumb').click(function(event) {

event.preventDefault();

var imageUrl = $(this).attr('href');

$('.photo-overlay').show().css('background-image', 'url(' + imageUrl + ')');

});

$('.close-photo-overlay').css('cursor' , 'pointer').click(function() {

$('.photo-overlay').hide();                                                                                                   

});

});

</script>

</head>

<body>

<div class="photo-overlay">

<div class="close-photo-overlay"><i class="fa fa-times"></i>

</div>

<!-- end close-photo-overlay -->

</div>

<!-- end photo-overlay -->

<div class="imgBox">

<a href="https://upload.wikimedia.org/wikipedia/commons/6/63/Monarch_In_May.jpg" class="thumb"><img src="https://upload.wikimedia.org/wikipedia/commons/6/63/Monarch_In_May.jpg" /></a>

</div>

<!-- end imgBox -->

<div class="imgBox">

<a href="http://cdn.funcheap.com/wp-content/uploads/2011/06/Butterfly_Beauty.jpg" class="thumb"><img src="http://cdn.funcheap.com/wp-content/uploads/2011/06/Butterfly_Beauty.jpg" class="thumb"/></a>

</div>

<!-- end imgBox -->

</body>

</html>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 24, 2015 Aug 24, 2015
LATEST

thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines