Utilizing innerfade plugin for displaying adaptive images on websites

After setting up a responsive design, I incorporated the innerfade plugin to create a carousel of pictures. However, I noticed that as the width of the page changes, the height of the pictures becomes smaller and fails to cover the entire area required. When the width reduces from 1440px to 320px, the image's height is only around 25 percent of the original div size. In my CSS, I have targeted img {width:%; height:auto;}. The containerheight in the jQuery is set at '100%'. I experimented with changing the counterheight within jQuery to 'auto' and adjusting the containerheight to a static '400px', but to no avail. How can I ensure that the image covers the entire div while still using innerfade? Any assistance would be greatly appreciated as this is my first time working with this plugin.

Answer №1

Modify the #test li to match the id of your ordered list. Replace 'wrapper' with the name of the div where the images will be placed. It's functional, just unsure how to include images here.

<script type="text/javascript">
$(document).ready(function(){

$('#test').innerfade();

$(window).on('load', function(){
var sample = $('#test li').height() + 5;
$('.wrapper').css({'height': sample});
});

$(window).on('resize', function(){
var sample = $('#test li').height() + 5;
$('.wrapper').css({'height': sample});

});

});
</script>
<style type="text/css">
.wrapper {
position: relative;
}
#test img {
height: auto;
width: 100%;
}

#test li {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
display: block;
top: 0;
left: 0;
padding: 5px;
width: 100%;
}

.clear {
clear: both;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<head>
<meta charset="UTF-8">
<title>test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="scripts/jquery.innerfade.js"></script>
<script type="text/javascript">
$(document).ready(function(){

$('#test').innerfade();

$(window).on('load', function(){
var sample = $('#test li').height() + 5;
$('.wrapper').css({'height': sample});
});

$(window).on('resize', function(){
var sample = $('#test li').height() + 5;
$('.wrapper').css({'height': sample});

});

});
</script>

</head>
<body>
<div class="wrapper" style="width: 100%; max-width: 700px; margin: 30px auto; background-color: #666; height: 500px;">

<ul id="test" style="margin: 5% auto; padding: 0; list-style: none;">
<li><img src="images/img1.jpg" alt=""></li>
<li><img src="images/img2.jpg" alt=""></li>
<li><img src="images/img3.jpg" alt=""></li>
<li><img src="images/img4.jpg" alt=""></li>
<li><img src="images/img5.jpg" alt=""></li>
</ul>


</div>
<div class="clear"></div>
<div class="wrapper" style="width: 100%; max-width: 700px; margin: 30px auto;">

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris elit est, rutrum quis commodo sed, pharetra id erat. Pellentesque vel suscipit velit. Nulla nec ante hendrerit, sagittis neque id, ultricies urna. Etiam luctus nisl ac cursus cursus. In nec viverra ligula. Nullam porta tellus sit amet convallis pharetra. In hac habitasse platea dictumst. Aenean suscipit pretium mi in luctus. Phasellus vestibulum sem dictum, porta quam convallis, sollicitudin augue. Quisque elit metus, tristique vel maximus a, congue at mi. Duis pharetra, massa vel maximus consequat, ex ipsum faucibus augue, ultricies eleifend nisi velit vel ex.
</p>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet accumsan justo. Maecenas eget luctus magna, in dictum ex. Mauris posuere risus et magna aliquet dignissim. Sed non condimentum enim. Sed gravida tincidunt arcu, id cursus velit. Donec sit amet consequat dolor.
</p>

</div>

</body>
</html>

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

The error message encountered is related to a problem with the e.slice function within the Kendo UI

Everything was running smoothly until serverGrouping feature was activated and I tried to group some data by dragging and dropping a column. An error message appeared on the JavaScript console: e.slice is not a function. I suspect that there might be an ...

Retrieve and dynamically load an entire webpage using AJAX

Although it's typically not recommended, I am interested in displaying the progress of a download on a heavy page to show the user when it's ready. Is there a way for me to track and display the actual progress of the download? Can I monitor how ...

Activate the end trigger with Scrollmagic

I am new to using ScrollMagic and have been able to understand how to trigger my animation based on the starting element and duration Is there a way to set an end trigger instead of a duration? let smcontroller = new ScrollMagic.Controller(); let smscene ...

What is the best way to make a JavaFX WebView the same size as the entire scene?

My goal is to have a JavaFX WebView that automatically resizes to fit the scene upon startup. Currently, I am focused on setting the initial size properly. @Override public void start(Stage stage) { try { Scene scene = new Scene(createWebViewP ...

Create a jQuery element callback

I am faced with a button that I need to call in order to retrieve its id number and then hide it. Here is the line of code for the button: <div id="follow_21" class="button rounded" title="">Follow</div> I'm ...

Get rid of the strange border on the material dialog

I am struggling with the Angular material 6 dialog component as it is displaying a strange border. I have attempted to remove it using the code below, without success. Interestingly, when I apply the style inline in the browser, it works fine. Any suggesti ...

Maintain consistency of elements inside a div even when its size is adjusted

I'm working on some code that's supposed to create a notebook opening effect, but I'm running into an issue. <html> <style> #container { position:absolute; width:570px; height:360px; } inn ...

Looking for a drag-and-drop solution using Vanilla Javascript, no need for jQuery

Looking for assistance with creating a click-and-drag solution for a background image using Vanilla Javascript. I came across a jQuery solution on Codepen, but I need help translating it into Vanilla Javascript. Draggable.create(".box", { ...

Enhance your inline <pre> text by adding a unique background color with CSS

How can I achieve the gray background color, like in this word, which is contained within an inline <pre></pre>? This is what I have attempted so far. The code snippet shows that the inline style works fine after the </pre> but not befor ...

Modifying the default class styles from Bootstrap based on the HTML displayed in Devtools

I am attempting to customize the styles of my application using bootstrap. Upon inspecting the HTML in Chrome Devtools, I found the following rendered code: <div data-v-256a5f3d="" data-v-7bf4ea52="" class="row bg-gray-200 bord ...

Using CSS to automatically adjust the width of a child div based on its content, rather than stretching it to fill the entire

I'm currently facing an issue with my CSS. Apologies for the vague title, but I'll do my best to explain it here. My problem lies within a parent wrapper div that is centered on the page. Within this wrapper, there is another child div containing ...

The functions .ajaxStart and .ajaxStop seem to be malfunctioning

Having trouble displaying and hiding a loading gif before and after an Ajax request using ajaxStart and ajaxStop. Here's what I have: HTML: <div id="loading" style="display: none"><img src="loading.gif></div> JS: $("#searchForm") ...

Session-Based MVC3 Modal Dialog DevelopmentDeveloping a Modal Dialog in MVC3

In my MVC app, data is specific to the year being worked. Therefore, it is crucial to ensure that the working year is set before any data retrieval process takes place. I previously sought advice on this matter and found a solution here. While this method ...

What is the best way to create a sliding animation on a div that makes it disappear?

While I may not be an expert in animations, I have a question about sliding up the "gl_banner" div after a short delay and having the content below it move back to its original position. What CSS properties should I use for this animation? Should I use css ...

How can I prevent a postback from occurring when using a jQuery dialog with a

$(document).ready(function () { $("#TaskCreatorDivButton").click(function () { $("#taskCreationForm").dialog( { width: "600px" } ); }); }); ...

Tips for automatically scrolling to the bottom of a page and focusing on an iframe

My website features a large banner image with content followed by an embedded YouTube video within an iframe. While the webpage is responsive, on mobile devices the header appears too big and users have to scroll down to see the video. I want the webpage ...

Adjust the dimensions of the embed code to specify a width and height

Looking to integrate Appreplica on my website for embedding content, but struggling with the length of the embedded window. My Tweets seem to extend beyond the page boundaries. ...

Send a JavaScript variable to Twig

I am trying to pass a JavaScript variable to a twig path but the current method I am using is not working as expected. <p id="result"></p> <script> var text = ""; var i; for (varJS = 0; varJS < 5; varJS++) { text += "<a href= ...

Is it possible for me to include the VSTO runtime in the packaging of my Outlook plugin for shipping

In certain installation scenarios, the Visual Studio Tools for Office run time may be missing on the end user's machine. This article discusses these scenarios and more: http://msdn.microsoft.com/en-us/library/ee712596.aspx Our plugin is designed fo ...

Tips for incorporating only the CSS portion of tailwind into your project?

I am looking to exclusively utilize the CSS portion of Tailwind. An admin is writing an article and wants to incorporate all Tailwind classes within it. However, since Tailwind classes are generated during the React project build, there's a possibilit ...