Image carousel with centered image that adjusts to different screen sizes

I have a slideshow set up with a simple fade effect and I want to make it full size responsive.

Even though I have the slideshow, fullscreen settings, and responsive code working properly, I am facing an issue where the image is not centered entirely when resizing it. To create the slideshow, I utilized a straightforward plugin that functions effectively.

I have experimented with numerous codes in an attempt to avoid using a pre-programmed slider.

In conclusion, I need my image to always be centered according to the window/screen size.

Code:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>xXxXx</title>
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="js/jquery.cycle2.min.js"></script>


<style type="text/css">

body {
    font-family:sans-serif;
}

.cycle-slideshow {
  position: fixed; 
  top: -50%; 
  left: -50%; 
  width: 200%; 
  height: 200%;
}

.cycle-slideshow img{
  position: absolute; 
  top: 0; 
  left: 0; 
  right: 0; 
  bottom: 0; 
  margin: auto; 
  min-width: 50%;
  min-height: 50%;
}
</style>
</head>

<body>

<div class="cycle-slideshow">
    <img src="slider/1.jpg" alt="slider 1">
    <img src="slider/2.jpg" alt="slider 2">
    <img src="slider/3.jpg" alt="slider 3">
</div>

</body>
</html>

Answer №1

Create a stunning full-width background image with DIV:

.full-bg-image {
  position: fixed; 
  top: -50%; 
  left: -50%; 
  width: 200%; 
  height: 200%;
}

.full-bg-image div{
  position: absolute; 
  background: none 50% / cover;
  top: 0; 
  left: 0; 
  right: 0; 
  bottom: 0; 
  margin: auto;
}
<div class="full-bg-image">
  <div style="background-image:url(//placehold.it/800x600/cf5?text=1)"></div>
  <div style="background-image:url(//placehold.it/800x600/f5c?text=2)"></div>
  <div style="background-image:url(//placehold.it/800x600/5cf?text=3)"></div>
</div>

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

Enhance data search functionality in asp.net mvc by customizing textboxes

Hello, I am currently using VS2010 with ASP.NET MVC 4 and Razor. Within my project's database, I have a table named "person". I am looking to customize the TextBoxFor in ASP.NET MVC so that as I type, the results will display similar to the attached i ...

Dynamically incorporating parameters into a function without any limitations

Is there a way to dynamically pass multiple arrays as function parameters and then store their values into a single array? I already know how to accomplish the second part, as shown below: function arrayfunction(/*arrays go here*/) { var allArrays = [] ...

Utilize Selenium in Python to choose an element

When working with the following HTML code: <div class="nav-category__col" id="category_nav_level_3" style="display: block;"> <input type="hidden" value="1" name="videogame_type" id="videogame_type"> <ul class="nav-category__list" adp ...

Rearrange object based on several criteria - JavaScript

var numbers = { "value": [{ "num1": 1, "num2": 10 }, { "num1": 15, "num2": 13 }, { "num1": 26, "num2": 24 }, { "num1": 6, "num2": 25 }, { "num1": 15, "num2": 20 ...

White edges on Firefox border-radius style

One issue in Firefox is its inability to properly handle the clipping of rounded corner elements, especially when multiple backgrounds are involved. This problem can sometimes be resolved by setting background-clip: content-box within a class for non-absol ...

How can I use the jQuery Fade function to target multiple items simultaneously?

Currently, I have a jQuery fade function that is used to hide and show reviews along with their respective authors. Initially, only the reviews were set to fade in and out, but now I wish to achieve the same effect for the authors as well. Below is the c ...

Unable to make changes to the text within the textarea field

Currently, I am in the process of creating a script to streamline the tedious task of providing teaching feedback. To scrape data such as student names and classes, I am utilizing selenium/python. While everything is running smoothly, I have encountered an ...

Tips on handling missing static files when using ExpressJS to host a single page application

When a query from the browser with "/_/*" is made in my application, it is directed to the static folder using the following code: app.use('/_', express.static(path.join(__dirname, '_'))); After that, all GET requests to / are routed ...

Retrieve HTML content from Vuetify components without displaying it on the webpage

I have a project where I need to retrieve the HTML code from various Vuetify components. Instead of just as a HTML string, I actually need it as a DOM element that can be easily added to the body. This is necessary for me to be able to utilize these compon ...

Utilizing Jquery to add a delay and animate the sliding up effect on a recently created element

I am looking to apply a slide-up effect to a newly created element after a specified delay. $("div[data-error='true']").delay(5000).slideUp(500, function () { $("#error-alert").remove(); }); $("div[data-success='true']").delay(5000 ...

Choose a row from a table by utilizing AJAX with jQuery

Need help with deleting specific table rows using AJAX? The goal is to send the ID and Printer Type values from the table data cells when a row is selected for deletion. <table class="u-full-width" > <thead> <tr> ...

How to style HTML li elements to wrap like sentences within a paragraph

I am looking to format text list elements in a way that they wrap like sentences within a paragraph. Here is the accompanying HTML & CSS code snippet that demonstrates how li element behaves when it exceeds the width of the ul container. ul { ...

Submitting data using AJAX yields results, but the contact form remains untouched

I have created an online quiz using jQuery. My goal is to send the results, along with the user's contact information, to the moderator once they submit it. I have managed to send the result information successfully. However, I am facing an issue whe ...

Display the information by using the getJSON function and iterating through it with

I am working on a project where I receive JSON encoded data from a PHP script using $.getJSON. This data consists of 10 datasets that I want to display by fading out the old content, replacing it with the new one, and then fading in the updated information ...

Unable to establish a local dependency link with npm

Attempting to connect my local project testabc123 to myproject using the usual method: cd testabc123 npm link cd ../myproject npm link testabc123 However, encountering an error message: npm ERR! code E404 npm ERR! 404 Not Found - GET http://registry.npmjs ...

When multi or upsert is set to true, MongoDB fails to update records and promises continue to fail

I am facing issues with updating records in MongoDB using mongoose. Although my code seems to be correct, it does not update the record as expected. Below is the code snippet: edit(req, res, next) { var WorkType = require('../models/WorkType'); ...

What exactly is the function of the NextPage feature in Next.js?

Recently, I began incorporating TypeScript into my Next project. Could someone clarify the purpose of the following code snippets for me? import { NextPage } from 'next'; export const Page: NextPage = () => {} After reviewing the documentation ...

Unable to retrieve local property when inside a Callback function in Ionic2

I am encountering an issue with my Ionic 2 app that utilizes Angular2. It is a basic problem, but it has been quite frustrating for me. Below is the component in question... import {Component} from "@angular/core"; @Component({ '<ion-content> ...

HTML display with two columns for books viewing

My Plan: I am working on incorporating HTML content from an external source into my app, displayed in a 2-column horizontal scrolling book format using a WebView element. I want it to resemble how the Edge browser presents an EPUB book, with seamless horiz ...

Parsing JSON data from a PHP response using jQuery

Here is the code snippet I am working with using jQuery: var dataString = "class_id="+class_id; $.ajax({ type: "POST", url: "page.php", data: dataString, success: function (msg) { //stuck here }, error: function () { ...