The background of the webpage section is being cropped on mobile devices

Currently, I am delving into the creation of a website completely from scratch to serve as an online CV for networking and job/school applications. My journey with HTML and CSS is relatively fresh, having started only about 5 months ago. Overall, things have been going smoothly except for one issue: on mobile devices, the background sections on my page are truncated instead of extending all the way to the right side of the screen. Interestingly, on desktop, it appears as intended. Any assistance or recommendations would be greatly appreciated as I find myself a bit lost on what steps to take next.

The following snippet comprises the HTML and CSS code from my page:

Various screenshots showcasing the desired layout on Desktop alongside the output on Mobile where the background experiences cropping can be viewed below:

[View Desktop Screenshot][1]

[View Mobile Screenshot][2]

Note: Despite trying to implement the specified code in my CSS file to set the widths of html and body elements at 100%, no significant changes were observed. Additionally, experimenting with adding width: 100% to the "section-segmenter" class did not yield the expected outcome either.

An update after editing: Implementing this code snippet within the head tag resulted in slight alterations, albeit merely squeezing the section further.

<meta name="viewport" content="width=device-width, initial-scale=1.0">

[![Mobile View][3]][3]

Update after edit: To address the issue more effectively on mobile devices, I incorporated a media query that expands the width of 'section-segmenter' to 1300px when the maximum screen width reaches 600px. This solution appears to alleviate the problem on mobile devices to some extent. However, recognizing it as a temporary fix, I plan to explore converting the units of the table widths on my site to percentages, as suggested by user David Taiaroa.

@media only screen and (max-width:600px){
    .section-segmenter:nth-child(even){
        background-color: var(--light);
        position: relative;
        left: 0;
        right: 0;
        z-index: 0;
        padding: 15px;
        width: 1300px;
    }
}
[1]: https://i.sstatic.net/OKxt5.png [2]: https://i.sstatic.net/McBuP.jpg [3]: https://i.sstatic.net/6HOMr.jpg

Answer №1

Your issue stems from having hardcoded widths for certain elements in your code.

When viewed on mobile screens, these elements exceed the viewport or screen width, causing content to extend beyond the right side of the screen. This not only creates the problem you're facing but also leads to other complications.

The situation worsened after adding the viewport meta tag because it exacerbated the existing problem.

I identified some elements with fixed widths that contribute to this issue:

#nav-table {
...
width: 1300px;
}


#bio-table {
...
width: 1200px;
}

#skills-table {
 .... 
width: 1200px;
}  

To address this, consider utilizing media queries to adjust CSS based on viewport changes,
for example https://www.w3schools.com/css/css_rwd_mediaqueries.asp
and/or using units like percentages or viewport width (vw) instead of fixed pixels.

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

Dynamic HTML and CSS Table Alignment Techniques

Issue Screenshot: Is there a way to properly align the right column of the table, particularly the Student NRIC row and School's? .formstyled { width:70%; margin-left:5%; } .formstyled input[type=text],input[type=password],text ...

Is there a way to prevent text flipping using CSS or jQuery?

Is there a way to prevent the contents of an object from flipping when it is rotated +180°? I want to keep everything inside readable and avoid any flipping effects. ...

Blurring of text that occurs after resizing in CSS

When I use scale transform to zoom a div in HTML, the text inside becomes blurred. Is there a solution to make the text clear like the original? @keyframes scaleText { from { transform: scale(0.5, 0.5); } to { transform: scale(2, 2); } } ...

Ensure consistent element heights within adjacent columns using CSS

My template looks like this: https://i.sstatic.net/hoLzR.jpg I am trying to keep the same height between each item in both columns, where the height is determined by the tallest item in each column when they are placed side by side. But on smaller screen ...

While using Tcpdf, I encounter an issue where the textarea value I pass is not being printed in the desired format

Currently, I am experimenting with TCPDF to create PDF files from HTML. However, I have encountered an issue where passing a variable containing text results in the text being printed on separate pages for each line. Is there a way to ensure that the tex ...

The Safari browser restricts interaction with password inputs but allows interaction with other types of input fields

My password input field is styled like this: <input class="genericButton" id="login-password" type="password" name ="password" placeholder="Password"> While everything functions correctly in Chrome, I encounter an issue with Safari. When I try to i ...

Responsive Design and Advertising with CSS Media Queries

For my application, I am utilizing Twitter's bootstrap (responsive) css. My goal is to incorporate banner ads in the sidebar section. However, due to different media query settings, the sidebar's width will vary, resulting in the need for the ban ...

guide on launching react with pure javascript

Is it feasible to operate react "straight out of the box" using only JavaScript? In essence, I am seeking a way to utilize react by simply utilizing notepad to create the page (without needing to install and configure node etc.). More specifically - 1) ...

Switch the Ionic Slide Box to the "does-continue" setting

Currently in the process of constructing a slide-box containing numerous items. I've borrowed the code from the example provided here for an infinite number of items, and it's performing well. However, I have a considerable yet finite amount of ...

Changing text color with JQuery animation

Is there a way to animate text color using jQuery/jQuery UI? I want the text color to change from #000 to #F00 when an event is triggered, then fade back to #000 over 3 seconds. I attempted using effect("highlight", {}, 3000) with the highlight effect, bu ...

What is the best way to navigate my Page while my Dialog Component is displayed?

Is there a way to enable scrolling on the background when a dialog component opens up? By default, scrolling is disabled when the dialog appears. How can we allow scrolling in the background? Here is the code snippet: import React, { useState } from &apos ...

Populate JQuery fields dynamically based on changing name elements

I am working on a section that displays products dynamically fetched from a database using an ajax call. The results vary, some are single-row while others have multiple rows. Initially, I have a placeholder row of HTML on the main page for data entry whic ...

What steps should be taken to avoid an event from occurring when an error message is encountered?

I have a dropdown list of cars where an error message is displayed if any of them becomes inactive. When the error message is shown, clicking on the Route Car button should prevent any event from occurring, i.e., no modal popup should be displayed. How ca ...

The Firefox form is experiencing issues when the cursor is set to 'move'

I have an HTML form with a specific code snippet: #stoppage_section .stoppage{ cursor: move; /* fallback if grab cursor is unsupported */ cursor: grab; cursor: -moz-grab; cursor: -webkit-grab; } <div id="st ...

Error: ajax is not defined and needs to be declared (repeated twice)

Currently, I have a form that requires processing using Ajax. <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script> <div class="column1"> <form class="form box" action="javascript:networkCheck();" ...

Limiting the movement of an HTML range slider within a specific range

Currently, I have a range slider that goes from 0 to 100, with the current value set at the maximum of 100. My goal is to set a limit of 50, so that the slider can only be moved between 50 and 100, and not from 0 to 50. I've created a jQuery handler ...

Tips for utilizing the if-else directive in an AngularJS controller

My current challenge involves HTML coding. <li><strong>Scrub:</strong> {{insuredProfile.permanentAddress.isScrubbed}}</li> This code displays either true or false. I want to show Yes for true and No for false. Using data-ng-if, ...

Tips for converting plain text output into HTML tags

I recently set up a contact form 7 on my website, and I'm trying to customize the message that appears after submission. However, I'm running into an issue when attempting to split the message into two different colors. I created a span class to ...

Tips for organizing CSS styles into common and unique statements

Is there a way to apply the same background style but different font styles to two elements without duplicating the style statement in the header part? ...

Ways to incorporate color gradients into the corners of CSS cards

Below is an example of a basic bootstrap card: Example 1: https://i.stack.imgur.com/DK2Sz.png I attempted to draw blue and green colors side by side, but was only successful in drawing blue as shown below: Example 2: https://i.stack.imgur.com/CcSzP.png ...