Attempting to create a CSS header that spans the entire width of the browser

For my website, I want to create a header that spans the entire width of the browser. Currently, all my content is contained within a wrapper div with a set width of 990px. The header should have a fixed position as well. However, when I try to adjust the CSS for the header, the title and navigation bar end up stacking vertically instead of remaining side by side.

<body>
    <div class="wrapper">
        <header class="header">
            <h1>Automotive Industries</h1>
            <ul class="navbar">
                <li id="contact" class="navlist"><a href="http://www.google.com">Contact</a></li>
                <li class="navlist"><a href="http://www.google.com">Services</a></li>
                <li class="navlist"><a href="http://www.google.com">About</a></li>
                <li class="navlist"><a href="http://www.google.com">Home</a></li>
            </ul>
        </header>
        <div class="main">
            <p>Welcome to the #1 stop in automotive today</p>
            <div class="article">
                <img class="image" src="http://cdnedge.vinsolutions.com/dealerimages/Dealer%204697%20Images/content/car-tire-repair.jpg">
            </div>
            
           <!-- more content -->
           
        </footer>
</div><!--end of wrapper-->

Answer №1

nav {
    ...
    width: 100%;
    min-width: 1100px;
    position: fixed;
    left: 0;
}

View the Example

If you are experiencing horizontal scrolling, it may be due to the site loading within a frame. Ensure the website is viewed in a full browser window.

Answer №2

To ensure your header spans the full width of the 990px wrapper, it must be placed outside the wrapper. Set the header's width to 100%, and make sure it is either at the root of the div structure or within another element that also has a width of 100%.

Answer №3

Because it's contained within the <div class="wrapper">, it appears that the functionality is not possible at the moment.

If you move it outside of the wrapper, it should start working as intended.

<header class="header">
            <h1>Automotive Industries</h1>
            <ul class="navbar">
                <li id="contact" class="navlist"><a href="http://www.google.com">Contact</a></li>
                <li class="navlist"><a href="http://www.google.com">Services</a></li>
                <li class="navlist"><a href="http://www.google.com">About</a></li>
                <li class="navlist"><a href="http://www.google.com">Home</a></li>
            </ul>
        </header>
 <div class="wrapper">

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

What causes the `d-none` class to toggle on and off repeatedly when the distance between two div elements is less than 10 during window resizing?

My primary objective is to display or hide the icon based on the width of the right container and the rightButtonGroupWrapper. If the difference between these widths falls below 10, the icons should be shown, otherwise hidden. However, I'm facing an i ...

Python: parsing comments in a cascading style sheet document

I am currently working on extracting the first comment block from a CSS file. Specifically, I am looking for comments that follow this pattern: /* author : name uri : link etc */ and I want to exclude any other comments present in the file, such as: /* ...

Having trouble creating multiple PDFs with mPDF without having to store them on the server

I am creating several PDF files in a loop using the mPDF library. Here is a snippet of my code: for($i=0;$i<=3;$i++) { $mpdf = new mPDF(); $stylesheet = file_get_contents('style.css'); $mpdf->WriteHTML($stylesheet,1); $mpd ...

Find out if the On/Off switch is in the "on" or "off

My HTML switch code is shown below: $('#myonoffswitch').click(function () { alert($('#myonoffswitch').val()); }); .onoffswitch { position: relative; width: 77px; -webkit-user-select ...

Implementing AngularJS drag and drop functionality in a custom directive

I am in search of an example that demonstrates similar functionality to the HTML5 File API using Angular-js. While researching directives for Angular 1.0.4, I found outdated examples that heavily rely on DOM manipulation. Here is a snippet of the pure Ja ...

Adjusting the height of a container dynamically in React while flex items wrap using CSS

In my React project, I have a container called "answers-container" with multiple buttons inside it, laid out using flexbox with flex-wrap: wrap to allow them to wrap onto the next line when the container width is exceeded. However, I'm facing an issu ...

Aligning a sprite at the center of a div background

My button has a unique design where it consists of a sprite set as the background image of a div. The sprite sheet is laid out horizontally, and I have also scaled down the source image to fit the div. .button { background: url(sprite.png); backgr ...

Switch up the appearance of a button by altering its image depending on the value it holds

There are two buttons generated dynamically (not within my control) that I would like to customize with different images. Since I can't actually change the button code, I believe I will need to utilize CSS to achieve this based on the CSS values. The ...

Ways to resolve issues with resizing div elements while waiting for JavaScript to load

Apologies for the lack of a clear title to describe my issue. My problem involves this snippet of code, where I am creating a label to show time to users. <div class="content"> <div class="container"> <div class="card"> < ...

Tips for resolving the issue of cypress automatically opening a new tab

Recently, I've encountered an issue while using Cypress to perform a test on my website. Every time I click on a button, it redirects me to a new tab, disrupting the flow of my test with Cypress. Despite trying to remove the "target" attribute using t ...

Which of the dynamically-generated submit buttons has been selected?

In a hypothetical scenario, imagine a webpage with multiple submit buttons generated through a PHP loop. Each button is named after the loop value, resulting in HTML code like this: <input type="submit" name="0" id="0" value="click me"> <input ty ...

Loop through items in a list using Angular.js and display each item within an <

I am facing an issue where the model returned from the server contains html tags instead of plain text, such as b tag or i tag. When I use ng-repeat to create a list based on this model, the html is displayed as pure text. Is there a filter or directive av ...

Quiz results are incorrect

I've been working on creating a quiz application using JavaScript only, but I'm encountering an issue with the scoring. Initially, I set the correct variable to 0 and intended to increment it by 1 each time a correct answer is selected. However, ...

What's preventing my link from opening?

I've written this code for two tabs: <li> <a href="#gallery_place" role="tab" data-toggle="tab"> <i class="fa fa-picture-o"></i> <?php _e("Gallery", ET_DOMAIN); ?> </a> </li> <li> <a href ...

tips for efficiently using keyboard to navigate through tabs in an unordered list

Utilizing unordered lists in this web application. I am looking to implement tab navigation with keyboard functionality. How can I achieve this? The first tab should contain text boxes, and when the user fills out a text box and presses the tab key, they s ...

What is the best way to have gulp monitor my sass file updates and generate a single css file?

I'm currently working on a project using ASP.NET MVC 5 framework and Visual Studio 2013. In order to automate the process of compiling my sass files and publishing them into a bundle.css file, I decided to utilize gulp. Here are the steps I took: I ...

The RGB values of a dynamically loaded image being drawn to a canvas in JavaScript are slightly off

After hosting some .PNG images on my NGINX webserver, I noticed a discrepancy in the RGB values when loading and drawing them on a canvas using context.drawImage(img, 0, 0); and retrieving the image data using context.getImageData(x, y, 1, 1).data. Interes ...

When choosing from multiple dropdown menus, the selected option should be hidden from the other dropdowns

I'm currently working on a project that involves designing a web form incorporating 3 select boxes with multiple questions. The concept is such that, if I choose the 1st Question from the 1st select drop-down, it should not be available in the 2nd sel ...

What is causing the slider image to be the only element that is not adapting to different screen sizes?

I am currently using the flexslider from woothemes and I am unable to understand why the image is consistently wider than the content when the browser window is resized or when viewed on an iPad/iPhone. Upon inspection, I couldn't find any styles on ...

Guide on incorporating a dropdown menu within a Jssor slider

I am facing an issue with trying to include a dropdown menu inside the Jssor slider. The menu does not drop down when placed inside it. Here is the code snippet: <head> <script src="jquery.js"></script> <script src="jssor.slider.min. ...