What could be causing my carousel slider images to not adapt to different screen sizes?

I recently added a carousel slider to my website, and while it looks great on larger screens like desktops and laptops, I noticed that the images are not scaling properly when viewed on smaller screen widths. This has resulted in non-responsiveness which is quite frustrating.

Despite trying to apply media queries, I couldn't get the images to scale correctly within the carousel.

Interestingly, other parts of the website seem responsive except for this particular carousel section, and I'm struggling to find a solution to make it work seamlessly with different screen sizes.

If you have any insights into what might be causing this issue and how I can go about fixing it, I would greatly appreciate your input!

$(document).ready(function() {

  let $slider = $(".sliderG");
  let sliderItem = $slider.children(".item.active");
  let i = $slider.children(".item");
  let ind = 0;

  $slider
    .children(".item")
    .each(function() {
      $(this).attr("data-index", ind++);
    });

  i.on("click", function(e) {
    const that = $(this);
    let dataIndex = that.data("index");
    $(".item").removeClass("active");
    that.addClass("active");
  });

});
.sliderG {
  width: 75%;
  height: 80%;
  position: absolute;
  margin: 0 auto;
  left: 0;
  right: 0;
  top: 50px;
}

.sliderG .item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  position: absolute;
  background: url(https://www.g-money.com.gh/wp-content/uploads/2019/06/squircle-minG.jpg) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  border-radius: 10px;
  transition: all ease 0.7s;
  z-index: 1;
  transform: scale(0.8);
  left: -300px;
  right: 0;
  margin: 0 auto;
}

.sliderG .item.active {
  left: 0;
  right: 0;
  z-index: 2;
  opacity: 1;
  background: #ccc;
  transform: scale(1);
}

.sliderG .item.active~.item {
  left: 0;
  right: -300px;
}

.sliderG .item.active+.item~.item {
  opacity: 0.3;
  visibility: hidden;
}

.sliderG .item.active+.item~.item:hover {
  opacity: 0.7;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='sliderG'>
  <div class='item'>
    <img src="https://www.g-money.com.gh/wp-content/uploads/2020/02/Sending-MoneyT-scaled.jpg" alt="G-Money Send Money">
  </div>
  <div class='item active'>
    <img src="https://www.g-money.com.gh/wp-content/uploads/2020/02/Generate-VoucherT-scaled.jpg" alt="G-Money Cash-Out at Agent">
  </div>
  <div class='item'>
    <img src="https://www.g-money.com.gh/wp-content/uploads/2020/02/Pay-MerchantT-scaled.jpg" alt="G-Money Pay Merchant">
  </div>
  <div class='item'>
    <img src="https://www.g-money.com.gh/wp-content/uploads/2020/02/Buy-AirtimeT-scaled.jpg" alt="G-Money Buy Airtime">
  </div>
  <div class='item'>
    <img src="https://www.g-money.com.gh/wp-content/uploads/2020/02/Bank-ServiceT-scaled.jpg" alt="G-Money Bank Account">
  </div>
  <div class='item'>
    <img src="https://www.g-money.com.gh/wp-content/uploads/2020/02/Withdrw-at-AgentT-scaled.jpg" alt="G-Money Withdraw at Agent">
  </div>
  <!--<div class='item'>
    <img src ="https://www.g-money.com.gh/wp-content/uploads/2020/02/Generate-VoucherT-scaled.jpg" alt="G-Money Pay Bill">
  </div>-->
</div>

Answer №1

Copy and paste the following snippets into your CSS file:

.imageGallery .photoElement img{
   display: inline-block; 
   width: 90%
}

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

Custom Pug design without any CSS files added

I am having trouble with my .pug template in my express project as it is not including its stylesheets. I have referred to the pug documentation but still can't figure out the issue. Any help would be appreciated! FILE TREE: views `-- index.pug `-- ...

Dealing with two AJAX posts on a single PHP page, where both posts are being sent to the same page without specifying a URL

Managing 2 posts on the same page to execute 2 different PHP scripts is my current challenge. Upon successful validation of all field data in the first POST, a new block will be activated. Within this new block, additional inputs will be displayed. Once t ...

What is the method for altering the choices within one selection based on the selection made in another dropdown menu

Welcome to the code snippet! <select id="type"> <option value="item1">item1</option> <option value="item2">item2</option> <option value="item3">item3</option> </select> <select id="size"> <option v ...

Rails Polymer is experiencing a glitch where the CSS and Polymer elements are not displaying correctly until a page refresh is

Whenever I first load a page, my polymer elements (like paper-input) fail to load their CSS properly. Here is an example of how the page looks before and after refreshing: https://i.sstatic.net/vsIpE.pnghttps://i.sstatic.net/YAFjP.png Below is the code sn ...

Is there a way to remain on the current page in WordPress after submitting a contact form?

I recently developed a personalized contact form within WordPress, utilizing PHP. The completed form successfully sends emails, but I am encountering an issue when users hit submit; instead of staying on the original page, they are redirected to a post pag ...

Develop a JavaScript function to generate a multiple selection form

Hey there! I have a question... Can I use JavaScript to create a multiple select form? Here's an example: <select name="item[]"> <option value="0">Option 1</option> <option value="1">Option 2</option> </select> &l ...

Uncertainties surrounding the complexity of this multi-stage form

Exploring this multi-step form I have a couple of questions: 1) Is there a way to transfer the value from the first step to the second step of the form? 2) How can I ensure that the datepicker value is not empty (to prevent user progress in the firs ...

Encoding a two-dimensional array into JSON format

In my PHP script, I am querying a database and formatting the results as JSON: $query = mysql_query($sql); $rows = mysql_num_rows($query); $data['course_num']=$rows; $data['course_data'] = array(); while ($fetch = mysql_fetch_assoc($q ...

Can you provide guidance on how to prioritize container div style over CSS class?

Here's the HTML code snippet I'm working with: <html> <head> <style> .text-box { color: red; } </style> </head> <body> <p class=&qu ...

Tips for determining the width of an image and utilizing that measurement as the height in order to create a balanced square image

I am currently facing an issue with my code that is used to retrieve the width of an image which is set in percentages. Although I am able to obtain the width in pixels, I am struggling with correctly inserting the variable into the CSS property value usin ...

Using Knockout for binding data to the view model

I am currently working with a view that includes the following code: @model Store.WebUI.Models.CartIndexViewModel @{ ViewBag.Title = "Your Cart"; } <script type="text/javascript" src="~/Scripts/knockout-3.4.2.js"></script> <script typ ...

The issue with the before selector causing the button label to overlap on top of the button remains

Check out the code snippet When hovering over the button, the "Sign Up!" label disappears. I tried adding color: rgba(32,32,32,1); to both the .button element and the ::before selector as a backup, but the label still won't display on top of the butt ...

Attempting to retrieve XML/JSON

I am struggling with extracting the first 15 words from a file using the API. I have attempted to do it with both XML and JSON, but keep encountering this error: XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on th ...

What is the best way to assign an ID to the initial table header in an asp:DataGrid for CSS styling purposes?

I am looking for a way to customize the first element in the table headers row using CSS without relying on :first_child selector. Example Code: <asp:TemplateColumn HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"> <Heade ...

Position the current div in the center of a bootstrap progress bar for mobile devices

I'm facing an issue with the bootstrap progress bar on my website, especially on mobile devices where it goes off the screen. I want the current page marker on the progress bar to be centered on the screen while allowing the bar to extend beyond the s ...

Utilizing Ajax-jQuery in Yii framework for Dynamic Row Generation

Struggling to come up with a solution on my own, I am reaching out for ideas from others. I have successfully implemented cJUIcomplete, but now I am focusing on Inventory Management. For the sale form, I envision structuring it like this: Product Name - ...

Retrieving a particular key and its corresponding value within a jQuery object

In my current project, I have a PHP associative array where I am fetching keys and values and passing them to a jQuery object: $names = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43"); $js = json_encode($names); echo 'var names= ' . $js ...

Determine the 'source' attribute value of the image (img) with a dynamically changing Id

Below is the code snippet: <img id="simple_captcha-ad089ff4819" src="/simple_captcha?code=a35401d"> The id of the above img tag changes constantly with each new action. For example, the next id could be "simple_captcha-sfw454sdfs". Therefore, I n ...

Can mouseenter and mouseleave events be implemented in Chart.js?

Currently, I am using the onHover function on each pie to implement some scale/zoom effect. However, I would like to switch to using mouseenter and mouseleave. When there is a mouseenter event on a pie, it should enlarge with scale/zoom effect, and when th ...

Tips for adjusting the width of the scrollbar track (the line beneath the scrollbar)

How can I style a scrollbar to match this specific design? https://i.stack.imgur.com/KTUbL.png The desired design specifies that the width of -webkit-scrollbar-thumb should be 5px and the width of -webkit-scrollbar-track should be 2px. However, it is pro ...