Guide on creating a JQM website with a stunning image carousel

I've experimented with several image carousels for my mobile sites, but none of them are delivering the results I seek.

What I'm looking for is something similar to this site:

If you view the above link on a mobile device, you'll notice the carousel. If the images are too large, they're cropped, centered, and zoomed to fit the screen. I'm trying to achieve a similar effect, but it's proving difficult.

As shown in the image above, there's a white gap between the image carousel and page number. I'd like to resize the images in order to fill these gaps without distorting the aspect ratio. Can anyone offer assistance or insights related to this website?

Answer №1

If you want to achieve this effect, you can utilize the OWL Carousel plugin available at:

To enable the image 'zoom' feature, simply specify the max-height and max-width css attributes in your styling, like so:

#owl-demo .item img {
    max-width: 100%;
    max-height: 100%;
    vertical-align: middle;
}

A live demonstration can be accessed through this DEMO link

Answer №2

Why opt for a similar carousel when you can use the one already present on that page?

Check out this live example: http://jsfiddle.net/Gajotres/PFqVs/

HTML:

<!DOCTYPE html>
<html>
    <head>
        <title>jQM Complex Demo</title>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
        <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
        <link rel="stylesheet" href="http://www.photoswipe.com/latest/photoswipe.css" />        
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
        <script src="http://thecodingwebsite.com/tutorials/photoswipe/klass.min.js"></script>            
        <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>            
        <script src="http://thecodingwebsite.com/tutorials/photoswipe/code.photoswipe.jquery-3.0.4.min.js"></script>    
    </head>
    <body>
        <div data-role="page" id="index">
            <div data-theme="b" data-role="header">
                <h1>Index page</h1>
            </div>

            <div data-role="content">
                <ul class="gallery">           
                    <li><a href="http://www.photoswipe.com/latest/examples/images/full/001.jpg" rel="external"><img src="http://www.photoswipe.com/latest/examples/images/thumb/001.jpg" alt="Image 001" /></a></li>
                    <li><a href="http://www.photoswipe.com/latest/examples/images/full/002.jpg" rel="external"><img src="http://www.photoswipe.com/latest/examples/images/thumb/002.jpg" alt="Image 002" /></a></li>
                    <li><a href="http://www.photoswipe.com/latest/examples/images/full/003.jpg" rel="external"><img src="http://www.photoswipe.com/latest/examples/images/thumb/003.jpg" alt="Image 003" /></a></li>
                    <li><a href="http://www.photoswipe.com/latest/examples/images/full/004.jpg" rel="external"><img src="http://www.photoswipe.com/latest/examples/images/thumb/004.jpg" alt="Image 004" /></a></li>
                    <li><a href="http://www.photoswipe.com/latest/examples/images/full/005.jpg" rel="external"><img src="http://www.photoswipe.com/latest/examples/images/thumb/005.jpg" alt="Image 005" /></a></li>
                    <li><a href="http://www.photoswipe.com/latest/examples/images/full/006.jpg" rel="external"><img src="http://www.photoswipe.com/latest/examples/images/thumb/006.jpg" alt="Image 006" /></a></li>
                    <li><a href="http://www.photoswipe.com/latest/examples/images/full/007.jpg" rel="external"><img src="http://www.photoswipe.com/latest/examples/images/thumb/007.jpg" alt="Image 007" /></a></li>
                    <li><a href="http://www.photoswipe.com/latest/examples/images/full/008.jpg" rel="external"><img src="http://www.photoswipe.com/latest/examples/images/thumb/008.jpg" alt="Image 008" /></a></li>
                    <li><a href="http://www.photoswipe.com/latest/examples/images/full/009.jpg" rel="external"><img src="http://www.photoswipe.com/latest/examples/images/thumb/009.jpg" alt="Image 009" /></a></li>
                </ul>
            </div>
        </div>    
    </body>
</html>   

JavaScript:

$(document).on('pagebeforeshow', '#index', function(){   
    var myPhotoSwipe = $(".gallery li a").photoSwipe({
        jQueryMobile: true,
        loop: false,
        enableMouseWheel: false,
        enableKeyboard: false
    });

    myPhotoSwipe.show(0);      
});

Note:

If you're interested in using a newer version, visit their Github page at: https://github.com/dimsemenov/PhotoSwipe. The original developer is no longer maintaining the code, so avoid using the code from the official site: www.photoswipe.com

Answer №3

Finally, I achieved the desired result I had been aiming for. Surprisingly, instead of using JavaScript, a CSS snippet was provided to help me enlarge smaller images to fit the size of the div without distorting them too much. Here is the compact CSS code:

.small{
transform:scale(1.42,1.42);
-webkit-transform:scale(1.42,1.42);
-moz-transform: scale(1.42,1.42);
-o-transform:  scale(1.42,1.42);
-ms-transform:  scale(1.42,1.42);

transition: all 0.65s;
-webkit-transition: all 0.65s;
-moz-transition: all 0.65s;
-o-transition:  all 0.65s;
-ms-transition:  all 0.65s;
}

Simply include this code in the image tag and it will work perfectly.

**Note:** In order for this CSS technique to be effective, ensure that the image is properly centered within the div.

As evident in the snapshot, the image has been magnified.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error retrieving resource: server returned a 404 status code indicating file not found for javaScript and CSS files

I can't seem to get my css and js files to load on the server. Here is how my file structure looks like: GAME_Folder https://i.sstatic.net/wzfB3.png HTML doctype html head link(href='https://fonts.googleapis.com/css2?family=Press+Start+2P& ...

What is the method to display all items in a Vuetify Data Table rather than limiting it to 10 rows?

I have implemented a data table from Vuetify in my project: <v-data-table :ref="`sortableTable${index}`" class="items-table-container" :headers="headers" :items="category.items" hide-default-footer> ...

unable to receive JSONP response through JQuery AJAX

How can I make a cross-domain request to invoke a REST service using Jquery ajax? Here is the code snippet I am currently using. The variables ad1, city, sp, pc, and cn are retrieved using getElementById: url='http://admin:admin@*******:***/rest/aru ...

Alter the content of a div depending on the values of three different elements

Hello everyone, I am new to the world of jQuery and javascript, and I am facing a challenge that I need some help with. Within a form, there are two fields that I would like to perform calculations on. Here is what I have attempted so far: jQuery.fn.calcu ...

Achieve a left-aligned text section that remains centered using Bootstrap 4

I encountered a problem with bootstrap-4. I tried centering a section using the text-center class: <div class="text-center text-left"> <h2>Hi,I'm,</h2> <h2>Bonheur jed,</h2> <h2>Web Developer.</h2&g ...

Adjust the HTML layout based on the JSON data provided

I am working with a JSON script that contains live matches, which change every 5 minutes. The changes could involve keys such as live_in or score. Matches are also being deleted and added to the JSON. I want to ensure that my HTML output remains updated at ...

The configuration of DataTables with the rowGrouping plugin and specifying aoColumns definitions encountered issues

Currently, I am in the process of working on a table that utilizes rowGrouping. Up until now, working with datatables has been smooth sailing for me. However, I have encountered some challenges with my current datatable implementation. The table is initia ...

What is causing this mysterious gap to appear between these two elements?

Can someone help me identify the issue between these two p elements? I checked the box model and there doesn't seem to be any margin set. Here is the fiddle and code for reference - https://jsfiddle.net/f3m2apgy/ <body> <style> #conta ...

What is the best method to center a div on the screen?

Is there a way to have a div open in the center of the screen? ...

Steps for adding a JSON object to an unordered list

After receiving data from a web server, I created a JSON object using the code obj = JSON.parse(data). This object contains information about dinosaurs such as their name, group, diet, and period. This is what the JSON object looks like: [{"name":"Stauri ...

Setting the default date in angular-bootstrap-datetimepicker: a step-by-step guide

I am currently utilizing the angular-bootstrap-datetimepicker module for allowing users to choose a date and time. How can I set a default date and time when the view initially renders? Is there an attribute available that allows us to assign a boolean val ...

implementing the CSS property based on the final value in the loop

I have created multiple divs with a data-line attribute. I am trying to loop through each div, extract the individual values from the data-line attribute, and apply them as percentages to the width property. However, it seems to only take the last value an ...

Display content in the View in ASP.NET based on the parameters passed into the ActionResult function

I'm grappling with a theoretical scenario involving rendering a single View with different content based on user input using MVC in the .NET framework. Essentially, I'm looking to have just one page titled "Create Template", but its contents sho ...

Dynamic forms with live updates in Django

I have a vision for my website where I want to incorporate a dynamic form that can be accessed and updated by multiple users simultaneously. The idea is that as one user makes changes to the form, those updates are immediately visible to all other users wi ...

Confusing day and month arrangement seen in Bootstrap UI DateTimePicker calendar popup

There seems to be a glitch in the Bootstrap UI + Bootstrap UI DateTimePicker combination (https://github.com/Gillardo/bootstrap-ui-datetime-picker) that is causing misleading days to appear on the calendar popup. Specifically, the numbers 31, 32, 33, 34, 3 ...

Tips for matching the height of a child div to its parent's height:

Is there a way to ensure that the height of the child div matches the height of the parent div without explicitly setting it in the CSS? Even when the parent div has a height of 300px, the child divs car1front and card1back do not seem to adjust accordingl ...

When one div is hidden, the width of another div will automatically adjust to 100%

Is there a way to make #leftdiv expand to 100% when #rightdiv is hidden, and have both <div>s positioned next to each other when a button is clicked? I have successfully aligned both <div>s next to each other upon button click, but I would lik ...

How do I utilize Protractor to target a specific div element with a distinctive class and verify its visibility on the page?

Below is the view.html for a unique class: <div class="appExperience small-tile"> </div> This is the code snippet that I attempted to use: var displayedTile = element(by.css('.appExperience small-tile')); expect(displayedTile.i ...

How about this: "Implement a slider in the header of a php

I am looking to add a slider to the header of my phpBB website. I have inserted the code into template/overall_header.html but it doesn't seem to be working. As someone who is new to phpBB, any assistance would be greatly appreciated. ...

Is it possible to disable the save option on a PDF popup window?

When displaying a PDF using an embed tag, I have managed to disable print and content copying through document properties. However, I am struggling to find a solution to disable the save option that pops up. Is there a way to achieve this using JavaScrip ...