Navigating horizontally in mobile safari

I need assistance with creating a web page that contains a black box at the center, with 30px padding on both the left and right sides.

Currently, my code works perfectly on desktop browsers without horizontal scrolling. However, when viewed on mobile Safari, there is an unwanted horizontal scroll. How can I fix this issue?

I have already tried applying overflow: hidden to the body, outer div, and inner div, but it did not solve the problem.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>hello world</title>
</head> 
<body style="margin:0;padding:0;">

<div style="padding:0 30px">
    <div style="background-color:#000;height: 50px;">

    </div>
</div>
</body>
</html>

Answer №1

Alright, the solution is to enclose the div with padding inside another div.

<body style="margin:0;padding:0;">
<div>
    <div style="padding:0 30px">
        <div style="background-color:#000;height: 50px;">

        </div>
    </div>
</div>
</body>

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

JavaScript - Unable to unselect a button without triggering a page refresh

I have a series of buttons in a row that I can select individually. However, I only want to be able to choose one button at a time. Every time I deselect the previously selected button, it causes the page to reload when all I really want is for all the but ...

In order for a page to display on a Firebase hosting URL, it must include the

I'm currently in the process of hosting a website using Google Firebase. The index.html is displayed as (for example) app.firebase.com, however, if I want to access a page like login.html, I have to enter app.firebase.com/login.html instead of just ap ...

Expanding Images in Bootstrap 4 Carousel

I am encountering some difficulties with a basic carousel implemented using Bootstrap 4. The carousel contains 3 images with the class d-block w-100, which is supposed to make the images stretch to the full width of the screen. However, in my case, the ima ...

Attempting to align my navigation bar beside my logo

I've been attempting to position my navigation menu next to my logo, but it keeps displaying below it. Although my coding skills are not top-notch, I am aiming to have the nav element positioned alongside the logo, as shown in my design: HTML: <b ...

Place my image in the center of the ul list item within a div

I am having trouble centering an image in my footer. I have tried various solutions but none seem to work. Can someone please take a look at my code and help me out? HTML <div class="center"> <ul> <li><a href="#" target=" ...

Unable to properly zoom in on an image within an iframe in Internet Explorer and Google Chrome

My image zoom functionality works perfectly on all browsers except for IE and Google Chrome when opened inside an iframe. Strangely, it still functions flawlessly in Firefox. How can I resolve this frustrating issue? The image link was sourced from the i ...

javascript tabs not functioning as expected in HTML

I am currently putting the finishing touches on a basic website for a project I'm involved in. The site features two tab controls - one on the right side of the page and the other on the left. Each control has 3 tabs that, when clicked, display differ ...

Locating the top 3 largest values in an HTML data table and highlighting them in red

Issue Description: I am working with data that displays the electricity consumption of different buildings in HTML tables. There is a possibility that these tables may contain duplicate values. With the use of jQuery, I am seeking a method to identify an ...

jQuery form validation with delay in error prompts

I am experiencing a strange issue with my HTML form validation function. It seems to be showing the alert div twice, and I can't figure out why this is happening. Adjusting the delay time seems to affect which field triggers the problem. Can anyone sp ...

Check out the CSS media query for screens with a maximum width on larger devices

Is there a way to preview a specific div and see how it appears on mobile devices? The HTML code for the div is obtained from an external source, like this: var external_html='<div>Responsive div</div>' + '<style>@media ...

Update the background's color by cycling through a set of colors stored in

I have a container on my webpage with a light blue background, and I want the background color to darken progressively with each click. Currently, I am manually setting an array of colors for this purpose, but I am struggling to make the background color c ...

How can progress bars be animated using CSS or JavaScript?

I am currently working on creating a progress bar animation, but I'm unsure whether to use CSS or JS. Can anyone provide insight on how this effect was achieved here? I am hoping to replicate it. Does anyone know if this is the code they used? I&apos ...

Adjusting the appearance of internal components with material-ui icons

Currently working on a project using react and material-ui where I am looking to customize the styles of specific elements within components. An example is the ListItem component which includes primaryText, leftIcon among others, and my goal is to modify t ...

When YII_DEBUG is disabled, the CSS will not be implemented

My website is built using Yii along with YiiBooster. Everything works fine when I am in DEBUG mode - all styles load and apply correctly. However, when I set YII_DEBUG to false in the index.php file, the CSS files still show as loaded in Firebug, but it ap ...

Adjusting label height with UIAppearance

Can UIAppearance be used to adjust the height of a label within a UINavigationBar? Take a look at the code snippet and image provided below to get a better understanding of the issue. [[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-5.0 f ...

Mastering the stable usage of $watchIncorporating reliable

Please review the following code snippet: front_controller $scope.month=monthNames[$scope.currentmonthnumber]; monthyeartransfer.setvalue($scope.month); $scope.monthchange = function(m) { $scope.month = m; monthyeartransfer.setvalue($scope.month); ...

Is there a syntax problem with the jQuery (this).next() statement that is causing it to not

Struggling with the implementation of a .next() selector. It seemed straightforward, but I must be missing something. Here's the current script that is not functioning as expected: $('.ITEM').hover(function (){ $(this).next('.ITEM ...

A guide to modifying the color of the Menu component in material-ui

Currently, I am utilizing the Menu component from material-ui and facing an issue while trying to modify the background color. The problem arises when I attempt to apply a color to the Menu, as it ends up altering the entire page's background once the ...

Guide on invoking getSelectedValues method on a SELECT element using MaterializeCSS

The situation is quite straightforward. My objective is to retrieve the selected values from a select box. The tools I am working with include MaterializeCSS and JQuery. Materialize offers comprehensive documentation on its Select Form Item. As per the d ...

Utilizing tables for inquiries in email communication

Currently tackling a basic mailer with html. It seems like tables are recommended and inline styling is the safer route. However, I'm encountering an issue where there's a mysterious space when setting up my td and I can't seem to pinpoint ...