iPhone 3GS and 4 not expanding DIVs by 100%

I've been encountering a significant issue with a div that's set to 100%. It displays properly on desktop screens, but on iPhones, there appears to be a gap on the right side. I've attempted to use the following CSS:

body
 { 
min-width:980px;
background-color: #fff;

Despite trying several other solutions found online, the problem persists.

I'm currently incorporating idangero swiper for the first time, and while it displays correctly on iPhones, the issue lies with the div itself.

Here is the relevant CSS:

#welcome{ 
width: 100%;
height: 256px;
background-color: #1e2f3f;
}

Below is the code snippet for the swiper:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/javascript"></script>

      <link rel="stylesheet" href="idangerous.swiper.css">
        <script src="idangerous.swiper.js"></script>    

        <script type="text/javascript">
        window.onload = function() {
          var mySwiper = new Swiper('.swiper-container',{
            mode:'horizontal',
            loop: true
          });  
        }


        </script>


  <style>
  .device {
    width: 980px;
    height: 528px;
    padding: 30px 40px;
    border-radius: 20px;
    background: #111;
    border: 3px solid white;
    margin: 5px auto;
    position: relative;
    box-shadow: 0px 0px 5px #000;
    margin: 0 auto;
  }
  .device .arrow-left {
    background: url(images/arrows.png); no-repeat left top;
    position: absolute;
    left: 10px;
    top: 50%;
    margin-top: -15px;
    width: 17px;
    height: 30px;
  }
  .device .arrow-right {
    background: url(images/arrows.png) no-repeat left bottom;
    position: absolute;
    right: 10px;
    top: 50%;
    margin-top: -15px;
    width: 17px;
    height: 30px;
  }
  </style>  

  </head>

    <body>
  <div class="device">
  <a class="arrow-left" href="#"></a> 
  <a class="arrow-right" href="#"></a>
  <div class="swiper-container">
    <div class="swiper-wrapper">

        <div class="swiper-slide"> 
           <img src="images/slide1.png"/>
        </div>

        <!--Second Slide-->
        <div class="swiper-slide">
          <img src="images/slide2.jpg"/>
        </div>

        <!--Third Slide-->
        <div class="swiper-slide"> 
          <a href="http://www.lbbacchus.com"><img src="images/slide4.jpg" alt=""/></a>       
        </div>
    </div>
  </div>
    <div class="pagination"></div>
    </div>

    <script>
    var mySwiper = new Swiper('.swiper-container',{
      pagination: '.pagination',
      loop:true,
      grabCursor: true,
      paginationClickable: true
    })
    $('.arrow-left').on('click', function(e){
      e.preventDefault()
      mySwiper.swipePrev()
    })
    $('.arrow-right').on('click', function(e){
      e.preventDefault()
      mySwiper.swipeNext()
    })
    </script>

Appreciate your help! :)

Answer №1

Have you ensured proper display on devices by using the viewport meta tag?

<meta name="viewport" content="width=device-width, user-scalable=false;" />

This adjustment ensures that your content will fit correctly within the device's screen size.

Without this meta tag in place and with a min-width:980px on the body, the page may appear zoomed out when viewed on devices with smaller screens such as iPhones (which have a width of only 320px).

For more information, visit: https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag

Answer №2

One option to consider is

$(function() {
  $('#welcome').css({ width: $(window).innerWidth() });
});

Additionally, as suggested by @RaphaelDDL, it is advisable to utilize

<meta name="viewport" content="width=980px" />

This solution typically helps eliminate the mentioned gap.

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

Conceal HTML Table Rows

I have a HTML table that showcases items and their respective daily information - usage, incoming shipments, and inventory. The goal is to initially hide the first two columns and reveal them on mouseover using jQuery. I am planning to assign a class to ea ...

Ways to alter the color of individual pseudo elements using a CSS loop

While working on creating a typewriter animation effect for my website using only CSS that I discovered through some online research, a question popped into my mind - is it possible to set different colors for each text in the animation? I have included t ...

Before clicking the submit button, send field values using Ajax

Is it possible to send values using ajax before submitting form data with a submit button? I have the code below. It successfully reaches the success function, but I am unable to retrieve the posted data. Any ideas on how to solve this issue? Your help an ...

The Ajax request functions flawlessly on Mozilla but encounters issues on Chrome, causing confusion as it occasionally works

I am using a PHP file with a class and function to store data in the database, accessed via AJAX. While everything works smoothly in Mozilla, Chrome seems to be causing some issues. Strangely, sometimes it works fine, but other times it fails for no appare ...

Can you customize the first element within a span tag using a for loop?

I am having an issue where only the last element in a span is being set within a for loop. The code is functioning correctly, but I want to ensure that the first element is the one set as cust_name. success : function(data) { co ...

Simple datetime selection feature in Django

I am looking to implement multiple datepickers in various pages on my website. I followed the instructions provided in this helpful guide for Fengyuan Chen’s Datepicker (the last link mentioned): When I create a standalone HTML page using the provided c ...

Can the default jQuery mobile ajax loader be triggered automatically when making a $.post() call?

Similar Question: Displaying Spinner on jQuery Mobile Ajax Call Is there a way to automatically trigger the default jquery-mobile ajax loader when using $.post()? For example, can I set up a global configuration for this behavior? I came across this ...

Vertically and horizontally align an SVG within 2 divs without modifying the parent div of the SVG

Is there a way to center an SVG both vertically and horizontally inside a div? The issue is that the width and height of the SVG are determined using the vx-responsive library, resulting in the following DOM structure: https://i.sstatic.net/3p2wc.png Edi ...

Unable to create a horizontal navigation bar

After spending a considerable amount of time on this task, I am perplexed as to why the navbar is not aligning horizontally. I have tried various techniques such as floating to the left and using display inline, but nothing seems to be working. Could there ...

Form data triggering inaccurate results in ajax response

After following online tutorials and seeking help from Stack Overflow, I am still struggling with a strange issue related to AJAX. I appreciate any assistance in solving this problem. I am trying to create a feature where users can search for match result ...

How can I transform a JSON object into a series of nested form fields?

Can anyone suggest a reliable method for converting a JSON object to nested form fields? Let's consider the following JSON object: {'a':{'b':{'c':'1200'}}}, 'z':'foo', 'bar':{&apo ...

Guide to implementing CSS3 transitions with prefixes using JavaScript

Is there a way to apply CSS styles using JavaScript when I don't have access to the CSS file? #fade div { -webkit-transition: opacity 1s; -moz-transition: opacity 1s; -o-transition: opacity 1s; -ms-transition: opacity 1s; transition: ...

Is it possible to determine which specific JavaScript function initiated the ajax call with jQuery's ajaxComplete function?

I currently have the .ajaxComplete event set up for a few elements in this manner: $("#ElementId").ajaxComplete(function (a, b, c) { }); The issue I am facing is that I have multiple $.ajax calls in my script triggered by different functions. I do not wa ...

Creating a Vue.js v-for loop to dynamically display a series of DIVs in segments

Here is the code I am currently working with: <div class="container-fluid" id="networdapp" style="display:none;"> <div class="row" > <div v-for="(result,i) in results" :key="i" class="col-sm-6" > <div class=" ...

Unfortunately, Safari and iOS do not support the video functionality

I am encountering an issue with my HTML5 sample video not loading in Safari 11 on OSX, but working perfectly fine in Chrome and Firefox. Additionally, the video is not functioning on iOS at all (neither in Safari nor in Chrome). Below is the HTML code: & ...

What steps can I take to ensure that this list remains fixed at the bottom of the page?

Looking to have this content positioned at the very bottom of my webpage without any empty space below it. I'm having trouble applying the usual CSS to achieve this. .footer li{ display:inline; } <footer> <div cla ...

Adjust the color of the text depending on the background it is displayed on

While practicing HTML and CSS as I normally do, I decided to work on a PSD template yesterday. Initially, it seemed straightforward, but soon I encountered the issue I'm currently facing. Specifically, I am trying to change a specific part of text ba ...

The SVG image exceeds the boundaries of the parent column div in bootstrap

I am struggling to make a SVG fit inside a column in a bootstrap div with col-lg-4. I tried using img-fluid, but it did not work as expected. The SVG should automatically adjust its size to fit the parent div. However, that is not happening. .star-ratin ...

Having trouble getting HTML to render properly in React JS on localhost using Apache server

For the past week, I've been working on resolving an issue. I started by creating a React Application using: npm create react-app After that, I attempted to build it with: npm run build Everything seemed to go smoothly. I generated a build folder ...

Having trouble using jQuery's .off() method to remove an event handler?

I'm facing an issue with my jQuery code where the .off('click') method doesn't seem to be working. I've tried removing the event binding from '.reveal-menu', but it's not working as expected. The initial animation wo ...