Menu bar does not extend fully across the screen

I'm struggling to get my navigation bar to cover the entire right side as seen in the picture. I've tried everything and still can't seem to figure it out. Any suggestions would be greatly appreciated.

<!doctype html>
<html lang="en">
<head>
<title>
Lighthouse Island Bistro
</title>
<link rel="stylesheet" type="text/css" href="tes.css">
<meta charset="utf-8">
</head>
<body>
<div id="wrapper">
<header>
<h1>Lighthouse Island Bistro</h1>
</header>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="menu.html">Menu</a></li>
<li><a href="map.html">Map</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
<main>
<h2>Locally Roasted Free-Trade Coffee</h2>
<p>Indulge in the aroma of freshly ground coffee. Specialty drinks are available hot or cold</p>
<h2>Specialty Pastries</h2>
<p>Enjoy a selection of our fresh-baked, organic pastries, including fresh-fruit muffins, scones, croissants, and cinnamon rolls.</p>
<h2>Lunchtime is Anytime</h2>
<p>Savor delicious wraps and sandwiches on hearty, whole-grain breads with locally-grown salad, fruit, and vegetables.</p>
<h2>Panoramic View</h2>
<p>Take in some scenery! <br> The top of our lighthouse offers a panoramic view of the countryside. Challenge your friends to climb our 100-stair tower.</p>
</main>
<footer>
Copyright &copy; 2016
</footer>
</div>
</body>
</html>

Here is my CSS:

body
{
background-color: #010d91; 
margin: 0;
}
#wrapper
{
width: 80%;
margin: 0 auto;
background-color: white;
color: black;
}
h1
{
font-size: 50px;
text-align: center;
}
header
{
background-color: #5995f7;
padding: 10px 10px 10px 10px;   
}
nav
{
float: right;
width: 150px;
font-weight: bold;
letter-spacing: 0.1em;
}
main
{
padding:10px 20px;
color: #000000;
display: block;
overflow: auto;
}
h2
{
color: #869dc7;
}
nav ul
{
list-style-type: none;
margin: 0;
padding: 0;
}
nav a
{
text-decoration: none;
padding: 20px;
display: block;
background-color: #89c6ed;
border-bottom: 1px solid #FFFFFF;
}
nav a:link
{
color:#ffffff
}
nav a:visited
{
color: #eaeaea;
}   
nav a:hover
{
color: #869dc7;
background-color: #eaeaea;
}
footer
{
text-align: center;
font-style: italic;
font-size: small;
padding-top: 5px;
padding-bottom: 5px;
background-color: #5995f7;
}

This is how mine looks: https://i.sstatic.net/VOKb5.png

I'm aiming for my navigation bar to expand to cover the entire width like in this example: https://i.sstatic.net/VDUZ0.png

Answer №1

I've made some updates to your code with a few changes, hoping it will assist you. Thank you.

Enclose your <nav> and <main> within <div id="content-wrapper">, then style the content-wrapper with CSS and also include background-color: #89c6ed; in the nav CSS.

#content-wrapper {
    display: flex;
    flex-direction: row-reverse;    
}

body {
    background-color: #010d91; 
    margin: 0;
}
#wrapper {
    width: 80%;
    margin: 0 auto;
    background-color: white;
    color: black;
}
h1 {
    font-size: 50px;
    text-align: center;
}
header {
    background-color: #5995f7;
    padding: 10px 10px 10px 10px;   
}
nav {
    background-color: #89c6ed;
    float: right;
    width: 150px;
    font-weight: bold;
    letter-spacing: 0.1em;
}
main {
    padding:10px 20px;
    color: #000000;
    display: block;
    overflow: auto;
}
h2 {
 color: #869dc7;
}
nav ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
}
nav a {
    text-decoration: none;
    padding: 20px;
    display: block;
    background-color: #89c6ed;
    border-bottom: 1px solid #FFFFFF;
}
nav a:link {
    color:#ffffff
}
nav a:visited {
    color: #eaeaea;
}   
nav a:hover {
    color: #869dc7;
    background-color: #eaeaea;
}
footer {
    text-align: center;
    font-style: italic;
    font-size: small;
    padding-top: 5px;
    padding-bottom: 5px;
    background-color: #5995f7;
}

#content-wrapper {
    display: flex;
    flex-direction: row-reverse;    
}
<!doctype html>
<html lang="en>
  <head>
    <title>Lighthouse Island Bistro</title>
    <link rel="stylesheet" type="text/css" href="tes.css">
    <meta charset="utf-8">
  </head>
  <body>
    <div id="wrapper">
      <header>
        <h1>Lighthouse Island Bistro</h1>
      </header>
      <div id="content-wrapper">
        <nav>
          <ul>
            <li><a href="index.html>Home</a></li>
            <li><a href="menu.html>Menu</a></li>
            <li><a href="map.html>Map</a></li>
            <li><a href="contact.html>Contact</a></li>
          </ul>
        </nav>
        <main>
          <h2>Locally Roasted Free-Trade Coffee</h2>
          <p>Indulge in the aroma of freshly ground coffee. Specialty drinks are available hot or cold</p>
          <h2>Specialty Pastries</h2>
          <p>Enjoy a selection of our fresh-baked, organic pastries, including fresh-fruit muffins, scones, croissants, and cinnamon rolls.</p>
          <h2>Lunchtime is Anytime</h2>
          <p>Savor delicious wraps and sandwiches on hearty, whole-grain breads with locally-grown salad, fruit, and vegetables.</p>
          <h2>Panoramic View</h2>
          <p>Take in some scenery! The top of our lighthouse offers a panoramic view of the countryside. Challenge your friends to climb our     
    100-stair tower.</p>
        </main>
      </div>
      <footer>
        Copyright &copy; 2016
      </footer>
    </div>
  </body>
</html>

Answer №2

When modifying your nav element, remember to include:

height:100%; 

Answer №3

To address the issue, consider incorporating height:100% into your navigation element as Ernie suggested.

If this solution proves ineffective, you may want to experiment with

nav { height: 100vh; }

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

Why does appending to a TextArea field fail in one scenario but succeed in another when using Javascript?

There is a JavaScript function that captures the value from a select dropdown and appends it to the end of a textarea field (mask) whenever a new selection is made. function addToEditMask(select, mask) { var selectedValue = document.getElementById(sel ...

issue arising from unique style identifiers in FireFox while making changes to styles via document.styleSheets

While experimenting with altering some stylesheets using JavaScript, I encountered an interesting issue: When attempting to set an attribute on a style rule in Firefox and the property is one of their proprietary ones, it fails silently. To demonstrate th ...

Acquiring the value of an input box in VBA through HTML

Can someone provide guidance on how to retrieve the value from an input box on an Internet Explorer page using VBA? I have tried various solutions but none seem to work. Below is the HTML code I am working with. I specifically need the value of the bolded ...

I'm facing an issue with my LAMP stack where the image appears when I access it through a URL, but doesn't seem to load when I try to load it using jQuery

My PHP file is located at path/renderer/renderImage.php and it generates a PNG image that displays correctly in the browser when I visit the URL directly. However, when I try to load this image into a DIV using jQuery from path/index.html with the followin ...

Error encountered when using the $.post function

$(".eventer button[name=unique]").click(function() { console.log('button clicked'); thisBtn = $(this); parent = $(this).parent(); num = parent.data('num'); id = parent.data('id'); if(typeof num ! ...

How do you vertically span a grid element across 3 rows using Material UI?

This particular scenario may appear to be straightforward, but the official documentation of Material UI lacks a clear example on how to achieve this. Even after attempting to nest the grid elements, I encountered an issue where the grid element on the ri ...

I am having difficulty centering the contents on the page horizontally

Struggling to achieve horizontal alignment, I suspect the floats are causing issues. Removing them disrupts the layout with left_wrap and right_wrap not staying next to each other. Check out this example on JSFiddle .main_wrap {width:100%;} .main_wrap_2 ...

Unexpected behavior with async pipe - variable becomes undefined upon reassignment

In my development process, I have implemented 2 components. One is responsible for fetching data from an external service, while the other one displays this data. The constructor of the first component is structured as follows: constructor( private dev ...

Concealing the WordPress sidebar specifically for mobile phones, excluding iPads, tablets, and other devices

I currently have Google AdSense displayed in the sidebar of my website, but it appears distorted when viewed on a mobile phone. My objective is to eliminate the sidebar when the site is accessed via a mobile device, while maintaining it for all other devic ...

Is it possible for a user to chat on Whatsapp by entering their mobile number in an HTML form within the app?

<?php require_once('./database.php'); if(isset($_REQUEST['submit1'])) { $number = $_REQUEST['whatsappnumber']; $code = $_REQUEST['countorycode']; $sql = "INSERT INTO whatsapp (whatsappnumber,counto ...

What is the best way to adjust inline svg to the user viewport size?

After working on integrating my interactive SVG maps into my HTML pages, I encountered a minor issue: when inserting my inline SVG into a standard, non-responsive HTML document, it automatically adjusts itself to fit nicely within the user's viewport. ...

When viewing the material-ui Chip component at normal zoom, a border outlines the element, but this border disappears when zoomed in or out, regardless of

Edit I have recently discovered a solution to the unusual problem I was facing with the material-ui Chip Component. By adding the line -webkit-appearance: none; to the root div for the Chip, the issue seems to resolve itself. However, this line is being a ...

Tips for utilizing the value retrieved from foreach within ng-repeat using angularjs

In order to display the field "seconddate" only if it is greater than "firstdate", a function needs to be implemented that will return true or false based on the comparison. The date format is in dd mmm yyyy (e.g., 22 Nov 2017). However, it is unclear how ...

Step-by-step guide to implementing a sticky header while scrolling

How can I implement a fixed header on scroll, like the one seen on this website: www.avauntmagazine.com Here is the HTML for my header: <div class="bloc bgc-wild-blue-yonder l-bloc " id="bloc-1"> <div class="container bloc-sm"> &l ...

PHP form script failing to process

I am experiencing an issue where my form keeps redirecting back to the main contact page without processing, even though the submit button was pressed and $_POST['contactsent'] is set to "yes". This indicates that the form should be processing. ...

What is the method for setting the doctype to HTML in JavaScript or React?

I created a canvas with a height equal to window.innerHeight, but unexpectedly it seems to have 100% screen height plus an extra 4 pixels coming from somewhere. I came across a solution suggesting that I need to declare doctype html, but I'm unsure ho ...

Emphasize the designated drop zone in Dragula

Incorporating the Dragula package into my Angular 2 project has greatly enhanced the drag-and-drop functionality. Bundling this feature has been a seamless experience. Visit the ng2-dragula GitHub page for more information. Although the drag-and-drop fun ...

CSS - selecting elements that are greater than a specific criteria N

I have multiple <p> tags in the body of my HTML. I want to display only the first two paragraphs and hide all the paragraphs that come after. However, the code I'm using doesn't seem to work as expected. <html> <head> < ...

Can you explain the difference between dots-per-CSS-inch and dots-per-physical-inch?

When accessing jsfiddle.net, I received the following message in the Chrome Developer Tools console tab: The message suggests using 'dppx' units instead of 'dpi' in CSS, as 'dpi' does not correspond to the actual screen den ...

Unable to navigate to specific tab in Laravel 6 navigation tabs using URL parameter (e.g. myweb/pages#tab1)

I'm having trouble navigating to the tabs pages, they only show up in the URL (myweb/pages#tab1 .. myweb/pages/#tab2 ..). Can someone please help me out? View image <div class="card-body"> <ul class="nav nav-tabs" id="myTab" role="tabli ...