Creating a rigid sidebar layout in Foundation 6 that won't collapse

Currently, I am in the process of creating a layout where the sidebar's size is fixed due to design constraints. However, while the primary content area can adjust nicely, we are facing issues with the sidebar element when it squeezes. To tackle this issue, I have been following suggestions from Miko found here. Even though those tips were originally for foundation 5, they worked well for me except that I had to apply the collapse class to all rows. It's important for me to maintain the gutters as per the foundation guidelines. To experiment, I created a sample layout using various colors.

.section {
  max-width: 400px;
  margin: 0 auto;
  position: relative;
}
@media (max-width: 600px) {
  .section {
    max-width: 1024px;
  }
  .section.sidebar-left {
    padding-left: 335px;
  }
}

.sidebar {
  position: absolute;
  min-width: 335px;
  top: 0;
}

.sidebar.sidebar-left {
  left: 0;
}
<div class="section sidebar-left story-grid">
    <div class="sidebar show-for-large sidebar-left" style="height: 100%; background-color: green;">Sidebar</div>
    <div class="row collapse" style="background-color: orange;">
        <div class="row collapse" style="height: 50px; background-color: blue;">Full Width</div>
        <div class="row collapse">
            <div style="height: 50px; max-width: 355px; background-color: pink;">Fixed Width</div>
        </div>
        <div class="row collapse">
            <div class="columns small-1" style="height: 50px; background-color: purple;">1 Column</div>
            <div class="columns small-1" style="height: 50px; background-color: purple;">1 Column</div>
           // More column entries...
        </div>
        // Additional row entries...
    </div>
</div>

The story-grid class doesn't have much impact other than altering font color and height for demo purposes. Here is the resulting output:

https://i.sstatic.net/r1xhh.png

This output is almost what I desire, but there is still one aspect missing – gutters. When I remove the collapse class, the visualization changes significantly like shown below:

https://i.sstatic.net/ksfVD.png

I demonstrated the issue by hovering over the content section, highlighting how the internal grid system extends beyond its parent boundaries. So, my main concern now is achieving the desired result without compromising on maintaining the gutters intact. How can I achieve this?

Answer №1

Success! I managed to make it work by removing the collapse class and adding this snippet to your CSS: .row .row { margin: 0; }

In Foundation, nested rows have a negative margin that varies with screen width. This solution should help you achieve your desired outcome.

I also tweaked your code from using @media max-width: 600px to @media min-width: 600px, as it didn't align with the displayed screenshots.

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

Having trouble with Jquery not applying or removing the selected class in the navigation menu

My website is built using PHP, with the index file dynamically loading pages from a folder named "pages." Additionally, I have the navigation menu stored in a separate file. I am attempting to highlight the text color when a link is clicked, but I am faci ...

Position two divs next to each other

Struggling to align two divs side by side and encountering issues. Despite researching similar problems on stack overflow, I can't seem to find a solution that works for me. Can someone spot any errors in my code? The second div is not aligned proper ...

Can you provide instructions on connecting a navigation bar button to a sidebar that appears when clicked?

On my webpage, I have three buttons at the top. One of them, the Contact Me button, is supposed to reveal a hidden sidebar on the left side when clicked. However, I am having trouble getting the sidebar to appear when clicking Contact Me. An example of wh ...

Maintain the hover functionality for touchscreens

Currently, I am developing a website with a feed of images using Instafeed.js. The process of pulling the images, likes, and comments is functioning smoothly. I have implemented a hover effect that displays the number of likes and comments on an image. Yo ...

Troubleshooting Problem with Accordion Size in CSS

I am facing an issue with a dropdown menu that I have created. The dropdown has parent and child rows to display controls, but the width of the Accordion is not stretching as expected despite being set to 100%. Using Chrome and Edge developer tools, I insp ...

generate an electronic communication using an HTML and PHP template

Currently, I am working on a PHP web application that requires sending emails in HTML format. To achieve this, I am utilizing the mail() function. My goal is to send emails based on a template file that is formatted in HTML and includes segments of PHP ...

Utilizing multiple classes in HTML for a button element

  I've recently come across the concept that elements can have multiple classes. It's interesting, isn't it? .rfrsh-btn { background-image:url(../../upload/rfrsh_nb_grey.png); ... } .submit { font-size: 0.85em; paddi ...

Increase the size of the class element when hovered over

I have assigned a class to the "next" and "previous" functions on my webpage, and I am interested in increasing their size on hover so that they take up more space and push the other elements aside. For example: When I hover over the NEXT button, I want i ...

How does CSS affect the size and performance of a website?

Examining the content of this css file (focusing on the last 5 lines specifically): #page section .s_1 { overflow:hidden; width:435px; float:left;} #page section .s_1 h1 { font-size:36pt; color:#001744; line-height:1.1; margin-bottom:64px;height:107px;} # ...

Dynamic Resizing of Facebook Page Plugin for Responsive Design

I'm currently using the Page Plugin widget from Facebook. The Facebook page mentions: If you wish to adjust the widget's width when the window is resized, you must manually refresh the plugin. Is there a way to dynamically modify the width of ...

Enhancing the appearance of text in an HTML-rendered UILabel in Swift with

I need to display HTML content in a native UILabel along with a custom font. To achieve this, I am using NSAttributedString and the code snippet below: func htmlAttributedString() -> NSAttributedString? { guard let data = self.data(using: .utf16, ...

Having difficulty automatically adjusting the width of HTML columns according to their content

I have a HTML table that I want to automatically set the width of the table columns, adjusting based on the content within. Despite setting the width to auto, as shown in the image below, the content in the ID column does not stay confined to a single line ...

Update the text in a personalized dropdown menu when an option is chosen

After spending some time working on a customized dropdown with the use of CSS and Vanilla JavaScript (Plain JS), I encountered an issue while trying to select and update the dropdown text upon clicking an option: window.onload = () => { let [...opt ...

Implementing full-height list elements using CSS

I'm still facing challenges with my lists... After receiving some assistance, I was able to create a horizontal list with perfect dimensions for my needs: each element taking up 33.33% width and adjusting its height based on the tallest element. I ac ...

Saving and restoring the cursor/caret position in CKEditor 4: A how-to guide

While browsing similar questions on this topic, I realized that none of them really addressed my specific issue (or maybe I just need a better understanding of the concept). Initially, I embarked on the journey to acquire and manipulate the caret position ...

Designing a pair of elements within a single container

I am trying to achieve a layout where Element 1 and Element 2 can grow independently in height. However, I want the container's height to always match that of Element 2, while allowing Element 1 to grow as much as possible without exceeding the height ...

Setting various font sizes for a single element

I'm looking to enhance my text by incorporating an embedded font in addition to Arial as a backup option. However, the embedded font requires a larger font size compared to Arial. Is there a way to ensure that when displaying the same text element, A ...

Having trouble with jQuery validation: Seeking clarification on the error

I have implemented some validations on a basic login page and added jQuery validation upon button click. However, the code is not functioning as expected. I have checked the console for errors but none were displayed. Here is the code for your review: ...

Issue with AnimeJS Motion Path causing element to deviate from desired SVG path

I'm attempting to use an SVG element and the AnimeJS library to make the orange marker follow the course of this RC car race track. https://i.stack.imgur.com/8FKHC.png Despite my efforts, I am encountering strange and undesirable outcomes. At times ...

Issue with Chrome styling of li and a elements persists after link click

In my current project, I am facing an issue with my menu displaying differently in Firefox and Chrome. When clicking on the links in Chrome, they tend to move around, disrupting the styling of the menu. A common suggestion I found was to use display: block ...