The navigation bar appears to have a different width on mobile view specifically on one page

I created a mobile view navigation that appears correctly on two out of three pages. It spans the full 100% width as intended, but on one page it extends beyond that and causes the layout to look distorted due to the larger navigation bar. I'm not sure why this is happening because the CSS should be consistent across all pages, and I have verified that the links are properly placed in the HTML.

You can visit the website at:

The issue occurs only in the contact section when viewed in mobile [responsive] mode. You will notice that there is horizontal scrolling available, indicating that there is extra space for some unknown reason.

<!DOCTYPE html>

<html lang="en">
<head>
<title>Rafael Caba</title>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="responsive.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro' rel='stylesheet' type='text/css'>
</head>

<body>

<header class="main_header">
<div class="header_wrapper">
<p class="main_title"><a href="index.html">Rafael Caba</a></p>
    <nav class="main_nav">
        <ul>
            <li><a href="index.html">Portfolio</a></li>
            <li><a href="about.html">About</a></li>
            <li><a href="contact.html">Contact</a></li>
        </ul>
    </nav>
    </div>
</header> <!-- end of header -->

<div class="container">

<section class="contact_content">
    <article>
        <p class="contact_title">Contact</p>
        <p class="about_name">Rafael Caba</p>
        <p class="about_webdev">Web Developer</p>
        <p class="about_webdev">New York, NY</p><br>
        <p class="about_email"><span>Email:</span> <a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5220333e223a313c2b122b333a3d3d7c313d3f">[email protected]</a>"><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1c6e7d706c747f72655c657d747373327f7371">[email protected]</a></a></p>
    </article>
</section> <!-- end of section -->

</div> <!-- end of container -->

<footer>
<div class="footer_wrapper">
    <ul>
        <li><a href="index.html">Portfolio</a></li>
        <li><a href="about.html">About</a></li>
        <li><a href="contact.html">Contact</a></li>
    </ul>
    </div>
</footer> <!-- end of footer -->

</body>
</html>


@media screen and (max-width:640px){

    .container{
        width:100%;
    }

    .main_header{
        width:100%;
    }

    .main_nav{
        background:#000000;
        width:100%;
        margin:0;
        height:80px;
    }

    .header_wrapper{
        width:100%;
        }

    .main_content{
        width:100%;
    }

    .about_content article{
        width:90%;
        margin:10px;
    }

    .contact_content article{
        margin:10px;
    }

}

Answer №1

To resolve the issue of horizontal scrolling on the contact page, include the following code within

@media screen and (max-width:959px)
...

.contact_content{
    width:100%;
}

Additionally, within the

@media screen and (max-width:640px)
block, add width: 90% to .contact_content article. The updated declaration will be as follows...

.contact_content article{
    width: 90%;
    margin:10px;
}

In order to simplify the process of creating responsive websites, it is advisable to utilize frameworks. Some popular options include...

  • skelJS
  • Foundation

Best of luck with your website development!

Answer №2

Hello Ralph,

I noticed in the style.css code that you have set the width to 960px for both .header_wrapper (line no 35) and .container (line no 11).

This setting will cause the content to overflow on all resolutions, resulting in a horizontal scroll bar being displayed. To fix this issue, you can use media screen CSS like the example below:

@media screen and (min-width:361px) and (max-width:480px){
.header_wrapper, .container{width:90%;}
}

With this code snippet, both .header_wrapper and .container will have a width of 90% on mobile devices with a screen width between 361px and 480px. I hope this solution makes sense to you.

If you have any comments or feedback, feel free to share them.

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

Can you remind me of the specific CSS class used for Internet Explorer in Twitter Bootstrap?

Currently utilizing Twitter Bootstrap and curious if there is a specific CSS class to designate IE browsers within the BODY or HTML tags. Interested in writing CSS specifically for all IE browsers. Aware that Bootstrap offers some CSS classes for IE brows ...

Tips for creating horizontal scrolling in the div element

I'm working with a div element that looks like this: <div id="tl" style="float:right;width: 400px; height:100px; background-color:Green; overflow-x: scroll;overflow-y: hidden;"> <div id='demo' style="float:left;height ...

Finding the next div by its ID using jQuery

Currently, the jQuery code provided only allows navigation from the Sport section to the Entertainment section. Is there a way to create a script that allows navigation between any div sections with just one piece of code? <div id="topBar"> &l ...

Identifying and detecting Label IDs when clicked using the for tag

I am facing an issue with labels and input fields in my code. I have multiple labels that trigger the same input field, but I want to know which specific label triggered the input field. <label id="label1" for="input1">Document1</label> <la ...

Need to know how to retrieve the li element in a ul that does not have an index of 2? I am aware of how to obtain the index greater than or less

I'm looking to hide all the li elements except for the one with a specific index. I've written some code to achieve this, but I'm wondering if there's a simpler way using jQuery. While jQuery provides methods like eq, gt, and lt, there ...

Two CSS borders of varying heights

Just wondering, can we achieve something similar to the style shown in the attachment using only CSS? <h3 style="border-bottom:1px solid #515151"><span style="border-bottom:3px solid #0066b3">HEADER</span></h3> ...

Guide on transferring three js variable to an HTML label element

For my project, I am looking to pass three js values to the label of a div. The desired output is: stWay: stProposer: stTime: hello John 2017-09-07 I have successfully programmed a button to make div1 a ...

Extension for web design snippet

My program creates dynamic html documents using specific parameters, but there is one section that remains static and is pulled from a local text file. What would be the most appropriate file extension to use for this particular snippet? htm(l): Although ...

Can a rotationX be applied within an existing rotationX?

I have a collection of 3 divs labeled a, b and c inside a container. The container is rotatedX by 90 degrees, giving the appearance that it is "lying on its back". Now, I am trying to rotate the a, b, and c divs so they appear to be "standing up" again. Ho ...

In order to properly set up Require JS, you will need to configure the JS settings

Is there a way to specify the path from any property inside the require JS config section? We are trying to pass a property inside the config like so: The issue at hand: var SomePathFromPropertyFile = "CDN lib path"; require.config({ waitSeconds: 500 ...

Switching between different views in Angular UI-router by selecting one UI-view over another

On my page, I have set up 2 ui-views. The top view contains a form and some controls, while the bottom view initially displays a few tables but should change based on the user's actions in the top view. I chose to keep this initial setup within a sin ...

Dots are used to indicate overflow of title in React Material UI CardHeader

Is there a way to add ellipsis dots to the title in my Cardheader when it exceeds the parent's width (Card width)? Here is what I have attempted so far: card: { width: 275, display: "flex" }, overflowWithDots: { textOverflow: &apo ...

Scrolling Down on a Jquery Login Page

I am currently utilizing JQuery version 1.4.2. My objective is to allow the user to scroll down to the login form by clicking on the 'login' option in the top menu, similar to Twitter's design. The implementation works impeccably with insert ...

Executing PHP code upon clicking an HTML button

I am currently in the process of creating a simple webpage that will execute a stress test and mimic a load on my web server. The PHP code for stress is functioning properly, however, when I attempt to click the button, nothing seems to happen. <?php ...

php - Can you identify the issue?

File Name: sms1.php Located at: Here is the PHP code for sms1.php: <?php //Variables to POST $user = "hidden"; $password = "hidden"; $mobiles = "$_POST[phone]"; $message = "$_POST[msg]"; $sender = "$_POST[sender]"; //Setting up CURL to send data via ...

Booking form pop-up appearing beneath the section

Currently, I am in the process of adding a booking form to the main page of . However, I seem to be encountering an issue where a popup appears below the section it is supposed to open within when selecting the number of persons. Despite adjusting the z ...

Need help automating clicking the download csv button with Selenium Python, but the button's class name changes when it's hovered over?

While attempting to save a csv file by clicking the download csv button on a website, I encountered an issue. It seems that the .click() action is not functioning as expected, and upon inspection, I noticed that the class-name of the button changes from &a ...

Knitting: exporting to HTML file while retaining formatting

Recently discovered the amazing knitr library in R, which looks great when viewed in the viewer. But unfortunately, the style gets lost when saved to an html file. Code library(knitr) library(kableExtra) some.table <- data.frame ( x = rep(1 ...

Printing a React component using a button causes formatting related to className to be lost, while printing it inline preserves the formatting

I've hit a roadblock in trying to figure out the React and printing issue for the past week and a half, and it feels like I'm going in circles. Despite finding some helpful solutions on Stack Overflow, none of them seem to work completely for me ...

Explore the possibilities with Intel XDK's customizable keyboard feature

I recently started using Intel XDK for development and I encountered the following issue: I have an input text field (HTML) and I need to restrict user input to only numbers, decimals, and negative sign when they click on the field. How can I achieve this ...