Expanding container for mobile devices

Hey everyone! I need some help with my website code:

<html>
    <head>
        <!-- extra code here -->
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <div class="screenFourth">
            <div class="container">
                <!-- many tags -->
            </div>
        </div>
    </body>
</html>

The issue I'm facing is that when I view the website on a mobile device, there is an empty space on the right side of the screen. Check out this image for reference: Empty space on the right side

My CSS code looks like this:

.screenFourth{
    background-image: url(...);
    background-size: cover;
    background-position: top;
    min-height: 1380px;
}

@media screen and (max-width: 760px){
    .container{ width: 100%; margin: 0 auto; }
}

Any suggestions on how to fix this problem? Thank you!

Answer №1

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
}

.screenFourth{
    background-image: url(...);
    background-size: cover;
    background-position: top;
    width: 100%;
    min-height: 1380px;
}

@media screen and (max-width: 760px){
    .container{ width: 100vw; margin: 0; padding: 0; }
}

Incorporate the following changes to your CSS stylesheet. I've adjusted the background width to 100% and included width: 100vw; in the container CSS. Using vw as a unit ensures the width is relative to the viewport. This modification should enhance the design.

Furthermore, removed the margin & padding from the HTML and Body tags for improved consistency.

REVISED HTML

<html>
    <head>
        <!-- additional code here -->
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0">
    </head>
    <body>
        <div class="screenFourth">
            <div class="container">
                <!-- various tags -->
            </div>
        </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

Is there a way to plot countries onto a ThreeJS Sphere?

Currently engaged in a project involving a 3D representation of Earth. Successfully created a 3D Sphere using ThreeJS ...

What methods can be used to prevent users from seeing the URL when submitting this form?

My form has numerous fields that I need to submit... When I submit these fields, I use the POST method to conceal the actual variables being passed to the PHP page. Unfortunately, I am unable to eliminate the complete link. Switching from GET to POST su ...

Is it possible for an Android app to detect changes in orientation while it is running in the background

Just a quick question related to the topic. Is it possible for an Android app running in the background to detect changes in screen orientation? I found this code snippet: public class MainActivity extends AppCompatActivity { @Override protected ...

Use jQuery to transfer groups of table rows to a newly relocated table data cell

First of all, I appreciate you taking the time to go through this explanation. My current challenge involves using jQuery to move sets of TRs to new positions in a table. While I can easily move the headers, I am facing difficulty with moving the actual da ...

What is the difference between class at DOM and className at component?

When passing the className props to the child component, sometimes the className for the active link is not correctly reflected in the DOM element during production: The child component (Link) receives the className prop for the active link from the paren ...

Put a pause on CSS3 animations

I have created a unique CSS3 menu item and I am looking to showcase the articles item in a special way: By clicking on the 4th item, it should display the first one, followed by the second one, then the third with a slight delay of 0.5 seconds between them ...

What is the lifespan of Shared Preferences, and are users able to modify them?

Regarding Shared Preferences, I need clarification on their lifespan and the ability for users to modify them. I plan to store the username in this space and it's important that users cannot tamper with this information. ...

I am struggling to successfully upload a video in Laravel

In this section, the Ajax functionality is used to add a video URL to the database. The values for the Video title and description are successfully being saved in the database, but there seems to be an issue with retrieving the URL. <div class="m ...

Tips for navigating between modal data in ng-repeat with the use of angular ui modals

I am new to Angular JS and I have a question related to populating data using ng-repeat from a local JSON file. When the data is clicked, it should display more detailed information about the selected company. Now, I want to implement the functionality for ...

Encountered a Gradle Build error due to duplicate files being copied into the APK's META

I encountered this issue as soon as I added the elasticsearch dependency: compile 'org.elasticsearch.client:transport:5.0.0' Here is the detailed error logcat message: Error:Execution failed for task ':app:transformResourcesWithMergeJavaR ...

I am a beginner in the world of Typescript/Angular, and I have encountered a compiling error TS2339. It seems that even when the condition *ngIf="x.length > 0;" should be false, the

I'm currently enrolled in a Typescript/Angular course where I am learning about the implementation of "*ngIf". During one of the lessons, the instructor provided an example using an empty array to demonstrate how it fails the condition and results in ...

What is the best way to enable users to edit the placeholder text in an HTML input field?

I'm dealing with a situation where I have the following code snippet: <input placeholder="something"> Typically, the placeholder text disappears as soon as the user starts typing. Is there a way to make it so that the placeholder text becomes ...

Is there a method on iOS for identifying when a web page is being displayed in an embedded browser and then navigating to the "actual" browser?

I've encountered an issue with my website's magic login links on mobile devices, particularly on iOS. When a user receives the email in the Gmail app and clicks the link, it opens in the embedded browser instead of the system browser. This means ...

Positioning a file drop area discreetly hidden behind a cluttered data-packed table

I have been experimenting with the ngx-file-drop module for Angular 4. Lately, I have been working on adding a file drop feature to a website that displays data in a table using *ngFor and *ngIf directives. My goal was to create a background drop zone beh ...

Issue encountered while adding file data to SQL Database via mssql php

I am attempting to store files (PDFs, images) in a database using PHP and MSSQL. <form role="form" action="kyc.php" method="post" enctype="multipart/form-data"> <div class="form-body"> <div class="row"> <div ...

Guide to dividing the screen into three horizontal sections

I am currently working on a website and trying to divide a page into three different sections: one for the title and a button, one for the content, one for the text input. . The issue I'm facing is that the divs are not filling the height and ...

Insufficient memory allocation: error code 8 on Android platform

I've gone ahead and set up Eclipse, the Android SDK Manager, and installed the necessary files for Android 4.22 in the SDK. I attempted to run a sample Android project but encountered an error: [2014-02-06 15:28:08 - myFirstApp] Android Launch! [2014- ...

Discover the neighboring characters of an element within a block of text

Recently, I encountered a unique challenge. My task involves identifying the first 3 characters before and after an anchor tag within a paragraph. For example: <p>This is <a href='#' id='lock'>a</a> test for an anch ...

What is the best way to seamlessly move an element from a margin-left position of -9999px back onto the page?

Here are some additional details - because of unusual restrictions with the YouTube API, I have to push a container off the page in order to create the illusion that the container is hidden. I accomplish this using the following CSS class: .my_hide{ ...

Position items within the dynamically generated div without appending them

Utilizing JavaScript, I dynamically generate a line but struggle to position two balls at both the 1/3 mark from the beginning and end. For reference, please view the image below. I aim to have two balls appear upon pressing enter in the input box. Despite ...