Set Blueprint container with a full-width background that fills the entire browser window

I'm currently utilizing the Compass framework in conjunction with the Blueprint framework.

Within my setup, I've configured a 24 column layout with a total width of 1000px declared in my base.scss file.

The HTML structure appears as follows:

<div id="menu">
  <div id="container">
     <div id="main-menu">
      <ul>
        <li>Link1</li>
        <li>Link2</li>
        <li>Link3</li>
      </ul>
     </div>
  </div>
</div>

Regarding the SCSS:

@import "../partials/base";
@import "blueprint";
@import "compass/typography/lists/horizontal-list";

#container{
  @include container();
}

#main-menu-container{
  background-color: red;
  min-width: 1000px;
  position: fixed;
  top: 0%;
  left: 50%;
  margin-left: 500px;

}

#main-menu{

  @include horizontal-list();
  @include span(24);
  border: red 1px solid;

}

Everything is functional, but now I aim to affix the menu at the top of the window.

The issue arises when applying position: fixed to any containers, as the background fails to stretch 100%.

I desire an effect similar to Facebook's menu where the background extends fully but the menu occupies the grid and remains centered:

How can Blueprint help me achieve this desired effect without necessitating the addition of superfluous div elements lacking semantic meaning?

Answer №1

This is the final code I came up with:

@import "../partials/base";
@import "blueprint";
@import "compass/typography/lists/horizontal-list";

#container{
  @include container();
}

#main-menu-container{
  background-color: blue;
  min-width: 1000px;
  position: fixed;
  width: 100%; //Make sure to set width explicitly
  top: 0%;
}

#main-menu{
  @include horizontal-list();
  @include span(24, true);
}

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

Efficiently reducing the size of a CSS selector string with javascript

Is there a library that already performs this function? I've only been able to find online tools. The reason I am interested in accomplishing this task using JavaScript is because I need to ensure that the strings a > b, a and a> b,a are conside ...

Create a pair of blocks that are identical in size and positioned next to each other

I am encountering difficulties with a seemingly simple task. Here is what I want to achieve: https://i.stack.imgur.com/z7ITk.png My goal is to have two red blocks of equal height, even if the content inside them varies in height. Using a table is not idea ...

What is the best way to conceal the arrow that is included with the datalist?

Recently, I began my journey in coding and encountered an issue with the arrow that appears along with the options in datalist. Here's a screenshot for reference: datalist arrow I attempted to solve this problem using the following code: input[type ...

The constant motion of jQuery images is mesmerizing

Having trouble with a slide effect in my project. I have set up 4 images, where images 3 and 4 should slide down when clicked. Additionally, a div element should come down from them. I'm new to this, so apologies if it's a simple question. Any as ...

Slider Volume with jQuery

Struggling to find a solution for this issue. Seeking some assistance. My goal is to create a basic volume slider. So, the orange section represents my volume slider. This is the jQuery code I am using: var mouseIsDown = false; $("#volSlider").on("mou ...

What is the process for attaching a right ribbon label onto a card in Fomantic UI components?

I am completely new to Fomantic (and web development in general) and I'm attempting to create a website featuring a card with a ribbon label on the right side. I saw similar designs in the documentation where they used a segment instead. However, when ...

Create a hyperlink to the tabbed navigation menu

I want to create links to the tabbed menu for my website. The homepage has 4 categories: car, van, truck, and special, each of which leads to the portfolio page. The portfolio page includes a simple filtered tabbed menu structured like this: <ul id="f ...

dealing with a problem with the bootstrap navigation bar concept

I’ve been struggling to align the menu and company name in a single row. Initially, I tried setting the company name followed by some spaces before adding the menu items, but it didn't work out as expected. I've been spending the last couple of ...

Can you guide me on setting a background image URL for rails using javascript?

Within my Rails application, I have a collection of content paired with image buttons (each piece of content has an associated image). When a user clicks on one of these buttons, my goal is to display the corresponding image. All of my images are stored u ...

Split Screen Text Comparisons

For some reason, I am finding it challenging to display two paragraphs side by side without disrupting the overall layout. If you would like a visual explanation of the issue, please check out this video: Video If you're interested in reviewing the c ...

Click event in jQuery to change the background color of <td> element

I'm still getting the hang of jQuery, so please bear with me. :) The purpose of this code is to color a square with the selected color when clicked if it's white, and turn it back to white if it's already colored. It works fine except for a ...

Troubleshooting the issue with padding in CSS not working when using window.print()

I need help creating a footer for my printed pages, but the footer is overlapping the content. I've tried adding padding-bottom to the @page CSS rule with the height of the footer, but it's not making a difference. Any suggestions on how to prop ...

What is the best way to define line length in Bootstrap?

I have the following HTML: .line { width: 100%; height: 14px; border-bottom: 1px solid lightgrey; position: absolute; } .circle { height: 24px; width: 24px; background-color: lightgrey; border-radius: 50%; display: inline-block; } < ...

Tips for positioning text underneath an image with HTML and CSS

I'm attempting to align two links below an image as text. The HTML I have works perfectly in Chrome and Firefox, but not in IE, where 90% of our internal users are. Here is the code: <div style="float: right;"><img src="sites/default/files/ ...

Tips for enabling autoplay for videos in Owl Carousel

I am facing an issue with implementing autoplay functionality for videos in an owl carousel. Despite trying different solutions found online, including this Owl Carousel VIDEO Autoplay doesn’t work, I haven't been able to make it work. Additionally, ...

"Exploring the Possibilities of Dynamic Styling with VueJS

I am facing an issue with a data property called editMode set on a Vueity Card. When I click on a button, the editMode switches to true and an icon appears on the v-img. However, I want to adjust the opacity of the image to 0.3 when editMode is true, witho ...

Children within a list are creating spaces between the main unordered list

I am working on a navigation bar with submenus. I would like the submenu ul to be 139px wide (so when hovered over, the dropdown box will expand to 139px). However, setting this width also results in a gap between the parent links. For illustration: In ...

Comparison of utilizing PHP within CSS versus Implementation through JavaScript [General]

Curious about the incorporation of PHP in CSS, especially in relation to my current Wordpress Theme project. I am aiming for high levels of customization and have been using a JS file to change CSS Properties through PHP. However, I'm not entirely con ...

Extend the background of the left sidebar completely to the left side

I'm working on a website with a fixed 960px layout featuring a light-gray sidebar and white background. I am aiming to center the content within the layout, but I need help figuring out how to make the sidebar background extend all the way to the left ...

What is the best way to style nodes in a Force Directed Graph using CSS in D3?

Currently, I am developing a Force Directed Graph using D3 and managed to make it work with svg circles for the nodes. However, when attempting to use div elements along with CSS left and top properties, the positioning of the nodes seems to be incorrect. ...