Ensure that the div spans the entire width of the page

When I click on the "hamburger" mobile navigation button, it brings up a div called #navigation. However, the positioning of this div within other divs causes it to extend to only 100% of the width of its container div, rather than the entire document.

In addition to this issue, there is also overlap between the navigation div and both the header div and the one below it. Ideally, I would like the navigation div to push the header up and the subsequent div down instead.

Moving the div out of the container could potentially solve these problems, but it would create complications with the full-size version of the page as the #navigation div is used for both versions with different styling. Below is the code snippet:

body {
    margin: 0;
line-height: 1.428;
}
.wrap {
  width: 90%;
  max-width: 71.5em;
  margin: 0 auto;
  padding: 0.625em 0.625em;
}
#header {
background: #442869; 
padding-top: 1em;
padding-bottom: 1em;
min-height: 6em;
}
#mobile-navigation-btn {
display: none;
float: right; 
}
#navigation {
display: block;
float: right;
}

#navigation ul {

list-style: none;

}

#navigation li {

display: inline-block;
float: left;
padding-right: 2em;
padding-top: 0.7em;
padding-bottom: 0.7em;

}
#navigation li:last-child {
padding-right: 0em;
}
#navigation li a {
color: #ffffff;
text-decoration: none; 
}

.show-menu {
text-decoration: none;
color: black;
background: #ac3333;
text-align: center;
padding: 20px 10px;
border: 1px black solid;


}

.show-menu:hover {
background: #ac1111;
}
#extra {
background: #222922; 
padding-top: 1em;
padding-bottom: 1em;
min-height: 2em;
color: white;

} ... 

Answer №1

To enhance the layout, consider applying position: relative; to #header, and then using position: absolute; for #navigation, accompanied by

top: 69px /*adjust to your desired position*/
within the
@media only screen and (max-width : 920px) {}

By utilizing absolute positioning, you can remove the element from the normal document flow.

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

Responsive Design and the Importance of Setting Min-Width in Bootstrap 3

After doing some research on Stack Overflow about defining a minimum width for a responsive layout in Bootstrap3, I encountered conflicting answers related to "media queries." My goal is to make my layout responsive up to a certain point. Once it reaches, ...

Can anyone provide a reference or resource that explains the best scenarios for utilizing display:block, display:inline, and display:inline-block, and the reasons behind their usage?

Can you recommend a quality article discussing the guidelines for using display:block, :inline, and :inline-block in CSS, along with explanations on when to utilize each one? Additionally, in what scenarios should we override the display property through ...

Is it possible for webpack to combine css/scss/less files without creating duplicate entries for required files?

Consider this scenario where I have two components that need the same utility css file directly. Component one: import component1Css from '/path/to/component1.scss' import someOtherUtilityCss from './path/to/some-other-css.scss' ... e ...

Postpone the execution of the toggleClass function

I have a tab that, when clicked, fades in to reveal content loaded with AJAX. However, the content loads immediately upon clicking the button. I attempted to use toggleClass with delay, but it was unsuccessful. How can I effectively delay the loading of t ...

Images positioned in the middle of two different parts of a webpage

My journey into HTML CSS involves creating a basic website that caught my eye, with the goal of positioning an image between two sections. In this example, we see the image lying between two sections. I'm curious to understand more about this partic ...

What are the steps to reposition a label in native script with CSS?

I've been attempting to adjust the positioning of the label on the page, but no matter what I do it refuses to budge. Here is the code snippet in question: <Label text="Hello" class="hello" @tap='hello' /> With the following CSS sty ...

When the tailwind utilities are implemented, they do not appear on the screen

Recently, I embarked on a project using Tailwindcss/Next.js and encountered an issue when trying to apply a box-like shadow to a button with a new utility in pure CSS. Despite my efforts, the changes don't seem to take effect. Can you spot what I migh ...

CSS - Activating hover effects through keyframes

I'm looking to create an image effect that pulsates like a heartbeat. The idea is for the image to pulse for 3 seconds, then automatically flip for 1 second before resuming the pulsating effect indefinitely. I've managed to make the image pulse, ...

Revolutionary newspaper design utilizing asp.net's C# web forms

Trying to create a dynamic newspaper layout using ASP.NET C# web form. Struggling to set the page layout size inside a slider and display specific news content on a new page when clicking on an area of the newspaper using Repeater or another suitable contr ...

Anchor scrolling implemented with fixed navigation bar

I'm attempting to create a fixed navigation with anchor links that scroll smoothly to the designated section. The challenge lies in the fact that my navigation is positioned near the bottom of the screen. As a result, when the user scrolls down and th ...

Tips for Keeping Footer Aligned with Content:

When checking out this website, you may notice that the footer appears to be affixed to the left side. The CSS code responsible for this is as follows: #footer { width: 800px; clear:both; float:right; position:relative; left:-50%;} I would appreciate it ...

Accessing a particular line within a <p> tag prior to a <br> element is the

I'm currently working on making some modifications to someone else's website and they've requested that I adjust the initial line of a repeating paragraph element. Here is an example of the existing content: <p> Cum soluta nobis eleif ...

Shifting the dropdown arrow to a different position within the navbar

In the R shiny application I am working on, I have a navbar with a dropdown arrow that I want to move inline instead of below the menu. https://i.sstatic.net/e6BZG.jpg Could this be related to the navbar toggle? https://i.sstatic.net/e7I87.jpg ...

What is the best way to increase the size of the input field to allow for more typing space?

My query is quite simple. Even when I set the height to 100px, the cursor still starts in the middle of the input box. I want the entire box to be utilized with the cursor starting at the top left corner for a more intuitive paragraph writing experience. ...

Styling Text with Shadow Effects in Mobile Web Browsers

I'm attempting to apply a text-stroke effect using text-shadow like this: .text-stroke { text-shadow: -1px -1px 0 white, 1px -1px 0 white, -1px 1px 0 white, 1px 1px 0 white; } Unfortunately, it's not rendering correctly on mobile versions of Fi ...

Icon and div-based carousel/slider for a unique visual experience

I have a project in progress that requires dynamically displaying icons based on the user's selection. These icons are essentially glyphs with a two-word title underneath them. Essentially, there is an <div class="col-md-9"> ...

How to use CSS float to align list items with different heights seamlessly

I am attempting to create two columns with a floated list. Each li element has a different height, and I want to achieve this layout without large spacing gaps. Here is the closest solution I have reached: http://jsfiddle.net/kR94q/1/ HTML Please note ...

Ways to enlarge a div and its contents when hovering over it?

I am struggling to create a div that expands on hover and have been unable to make the content expand along with the div. I've experimented with various overflow options, but none of them seem to work. .grow { padding: 5px 5px 5px 5px ...

Trigger responsiveness issues with Bootstrap

Currently, I find myself in a somewhat awkward situation. I have developed a website using Bootstrap 4 (with Compass as a Ruby gem). However, due to ongoing discussions about its appearance on mobile devices, the client has requested that I revert the page ...

Make a gap between two buttons on my banner

How can I create a space of 0.5 cm between 2 buttons in my banner? I have been stuck on this for a while now. Do I need to modify my HTML blocks? https://i.sstatic.net/74yBh.png Below is the CSS code I am currently using: .myButtonRegister{ float: left ...