HTML - Oversized Header Extending Beyond Screen Width

I'm currently building an HTML web page and encountering an issue with the header. It seems that the header is wider than my screen size, resulting in a horizontal scroll bar appearing. I've tried some solutions, but none of them seem to work. Any insights on why this might be happening?

Here's the code for my header:

<header>
    <!--NAV BAR-->
<nav class="navbar navbar-expand-lg navbar-dark fixed-top elegant-color-dark">
    <div class="container-fluid">
        <!-- NAV BRAND-->
        <a class="navbar-brand" href="index.html">
            <img src="http://eprticher.mx/images/tich.gif" height="30" class="d-inline-block align-top mr-2" alt="">
            TICHER | Seguridad Privada
        </a>

        <div class="navbar-nav navbar-right">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" href="index.html">Inicio</a>
                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" id="dropMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Servicios</a>
                    <div class="dropdown-menu dropdown-primary" aria-labelledby="dropMenu">
                        <a class="dropdown-item" href="servicios_seguridad.html">Servicios Seguridad</a>
                        <a class="dropdown-item" href="tranp_ejecutiva.html">Transporte Ejecutivo</a>
                    </div>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="quienes_somos.html">¿Quienes Somos?</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="porque_elegirnos.html">¿Porqué Elegirnos?</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="contactanos.html">Contáctanos</a>
                </li>
            </ul>
        </div>
    </div>
</nav>

And here's the CSS code related to the header:

body {
background-color: #ffffff;
padding-top: 60px;
}

header {
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box;    /* Firefox, other Gecko */
box-sizing: border-box;
}

.sizeAdj img {
 width: auto;
 height: 500px;
 max-height: 500px;
}

.img-resp {
 width: 100%;
}

/* More CSS styles... */

The Header CSS modification was one solution I attempted, but unfortunately, it doesn't seem to be effective...

Snapshot of the problem...

When incorporating the header into another HTML file, I follow this structure:

<!DOCTYPE html>
<html lang="en">

<!-- Head section with necessary links and scripts -->

<body>
<div id="header"></div>

<!-- Main content section -->

<div id="footer"></div>
</body>
<!-- Scripts section with required JavaScript libraries -->
</html>

Answer №1

To solve the horizontal scrollbar issue, apply the following CSS:

body .navbar-nav{
    margin-right: 0px;
    margin-left: 0px;
}

body .navbar-nav{
margin-right: 0px;
margin-left: 0px;
}

body {
background-color: #ffffff;
padding-top: 60px;
}

header {
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box;    /* Firefox, other Gecko */
box-sizing: border-box;
}



.sizeAdj img {
 width: auto;
 height: 500px;
 max-height: 500px;
}

.img-resp {
 width: 100%;
}

.img-resp-sm {
 width: 50%;
}

.carousel-caption {
  position: absolute;
  bottom: 40%;
  left: 15%;
  z-index: 25;
  /*background: rgb(68, 68, 68);*/
  color: white;
 }

.separator {
  height: 1px;
  border: none;
  color: #bdbdbd;
  background-color: #bdbdbd;
 }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<nav class="navbar navbar-expand-lg navbar-dark fixed-top elegant-color-dark">
    <div class="container-fluid">
        <!-- NAV BRAND-->
        <a class="navbar-brand" href="index.html">
            <img src="http://eprticher.mx/images/tich.gif" height="30" class="d-inline-block align-top mr-2" alt="">
            TICHER | Seguridad Privada
        </a>

        <div class="navbar-nav navbar-right">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" href="index.html">Inicio</a>
                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" id="dropMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Servicios</a>
                    <div class="dropdown-menu dropdown-primary" aria-labelledby="dropMenu">
                        <a class="dropdown-item" href="servicios_seguridad.html">Servicios Seguridad</a>
                        <a class="dropdown-item" href="tranp_ejecutiva.html">Transporte Ejecutivo</a>
                    </div>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="quienes_somos.html">¿Quienes Somos?</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="porque_elegirnos.html">¿Porqué Elegirnos?</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="contactanos.html">Contáctanos</a>
                </li>
            </ul>
        </div>
    </div>
</nav>

</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

The issue of pseudo elements not functioning properly in Material-UI makeStyles with React.js has been a frustrating

The use of pseudo elements in Material-UI makeStyles is not functioning correctly. innerBox: { borderRadius: "10px", background: "#fff", boxShadow: "0px 1px 3px 0px rgba(0, 0, 0, 0.36)", maxHeight: "50px", "& ...

The ngClass directive did not expect the token '=='

Hey everyone, I'm currently facing an issue while trying to use multiple expressions in my ng-class directive. Unfortunately, the browser console is throwing this error: Error: [$parse:syntax] Syntax Error: Token '==' is unexpected, expecti ...

Is there a method available for downloading the HTML5 attribute that functions in Internet Explorer?

Is there a method to download attribute work in Internet Explorer. When attempting to force download a file on IE using The following works flawlessly on Firefox but not on IE <a href="image.jpg" download>Click here to download</a> ...

Tips for maintaining space beneath an image when text wraps around it

.blogimgarea { width: 38%; padding-right: 26px; float:left; } img{max-width:100%} .blogtextarea { width:55%; padding:22px 32px 0 0; float:right; } <div class="newpostregion pt70"> <div class="blogimgarea"> <img class="featblogimg" src="https ...

styled-components: the parent's styles take precedence over the child's styles

image export const LogOutButton = styled.button` display: inline-block; .... `; export default styled(ThemedApp)` .... button { .... display: flex; .... } `; Upon inspection, it is evident that the Logout button (with class gBuhXv) ...

Artwork - Circular design disappears without warning

While working on a clock project purely for enjoyment, I noticed that the minute arc disappears from the canvas as soon as a new minute begins. Any idea why this is happening? Check out the clock in action: https://jsfiddle.net/y0bson6f/ HTML <canvas ...

Guide to automatically update div with new table rows with the help of Ajax

Can you assist me in updating the div called "table" that contains a table fetching rows from the database? <div id="table"> <h1 id="Requests"> <table></table> </h1> </div> <button id="refresh-btn"&g ...

Create a stylish card layout using Bootstrap featuring a 3D icon design

I am currently working on accomplishing this layout using Bootstrap 4 along with some custom CSS styles. https://i.sstatic.net/t3tot.png This is the code I have implemented so far: <div class="container"> <div class="row"> ...

Creating a CSS binding for width: a step-by-step guide

I have a complex layout with multiple elements in different divs that need to be aligned. Hardcoding the width or using JS on page load to specify values in pixels both seem like messy solutions. How can I achieve this without causing a zigzag effect? Her ...

Bringing HTML into Excel with VSTO

I have encountered an issue while trying to import data from HTML files into Excel using VSTO (VB.NET). I am facing errors as I attempt to parse the HTML, and since I am new to this process, I need assistance in figuring out where my code is incorrect. I ...

Angular.js <div ng-include> not expanding to the full height of the viewport

My goal is to create a single-page app with a scrolling effect using Angular.Js. Each ng-include section within the <div class="viewport" ng-include="'views/file'" ng-controller="MainCtrl"></div> should fill the viewport entirely. How ...

My Bootstrap navbar seems to be malfunctioning. I'm wondering if there could be an issue with

here is a snippet of the code I'm working on: <nav class="navbar navbar-expand-md navbar-dark bg-dark sticky-top"> <div class="container-fluid"> <a class="navbar-brand" href="#"> <img src="https://i.stack.imgur.com/5XeYV.png" ...

What is the best way to transform data from a single form into a JSON array?

explore (handlebars) {{!< main}} <form class="ui form" action="/design/add" method="POST"> <div class="order_list"&yt; <h1>Add Product</h1> <br> {{!-- <input type="f ...

Should we still be using <input type="date" /> in 2021?

I've come across some old articles cautioning against using , but they were written a couple of years ago. I'm wondering if it's safe to use in 2021 without negatively impacting the user experience. ...

Issue with div:after transition not functioning in Safari

The transition effect on div:after does not function properly in Safari. Below is the code for reference: HTML: .bbtn { width: 151px; height: 48px; background: #ef2e41; margin: auto; margin-top: 32px; -webkit-transition: all 0.3s ease-in-ou ...

Alter attribute with an impact

I am looking for a solution to switch the image source using attr, while also incorporating a fade effect in the process. I have attempted to implement one of the suggestions from another post, but it is not producing the desired outcome. Current Appearan ...

Choosing descendant elements in CSS styling

Is there a way to select child elements in sequence? For instance: <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li> ...

Grid layout with Tailwind

I'm facing a challenge in my Angular project where I need to create a grid layout with 2 rows and 6 columns using Tailwind CSS. The actors array that I am iterating through contains 25 actors. My objective is to show the first 12 actors in 2 rows, fo ...

Table with checkboxes for row selection

Hey there, I've just set up a table with some values. My goal is to select all checkboxes with the first checkbox and uncheck them. print "Content-type: text/html; charset=iso-8859-1\n\n"; my $script = qq{ \$('#id').change(fu ...

CSS selector targeting an element based on the value of its table border

Is there a way to target a table on a webpage using a CSS selector? The table structure looks like this: <table border="1" width="560" cellspacing="0"> <tr> <td height="28" colspan="3" bgcolor="#FFFFF...> </tr> </table ...