Leverage the Width of a Nested Row within Foundation Framework

Here's a different layout option with a sidebar

<div class="row">
  <div class="main-content columns small-6>
     {main content}
  </div>
  <div class="columns small-6>
    {sidebar}
  </div>
</div>

And here is another layout without a sidebar

<div class="row">
  <div class="columns small-12">
    {main content}
  </div
</div>

When it comes to the main content section, the code looks like this

<ul class="small-block-grid-1 medium-block-grid-2 large-block-grid-3">
  <li>item one</li>
  <li>item two</li>
  <li>item three</li>
</ul>

In Layout 2, the main content adjusts properly at different screen sizes. However, I am looking for a way to have the block grid adapt based on the available width inside the parent section instead of the total screen width.

For instance, in Layout 1 where the main content column is 450px wide, the block grid should automatically adjust to "small-block-grid-1", regardless of the overall screen size being greater than 900px (medium size).

Answer №1

Foundation media queries do not function that way. The 'small' query is triggered by screen width, not the width of its parent. Nested rows are positioned relatively and their width is inherited from their parent element. You can modify this behavior in the sass settings file by adjusting the variable:

$block-grid-media-queries: true;

You can set it to false and create your own custom media queries.

According to Foundation documentation: You have the option to further customize your block grid using parameters in the block-grid() mixin:

.your-class-name {
      @include block-grid(
    // Determines how many elements appear on each row of the block grid. Choose any number up to the maximum specified in the variable.
    // Available options: 1-12 or false by default
    $per-row: 3,

    // Controls the spacing between items in the block grid.
    // Use a variable, pixel, or em values.
    $spacing: $block-grid-default-spacing,

    // Decide whether base styles are included or not. Set to false to exclude.
    $base-style: 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

Include an additional Div tag in the existing row

I've been attempting to include an additional div, but it consistently appears as the second row.. I want all of them to be on the same row and aligned with each other. Here is the HTML code: <div class="content-grids"> <div clas ...

Personalize the md-tab component in Angular 2

I'm encountering an issue with styling the md-tab component in Angular 2. While I understand that Angular 2 Materials is currently under development, I am wondering if there is a way to customize it, such as removing the bottom-radius. Below is an exa ...

Tips for avoiding repetitive animations when using jQuery animate toggle

Check out my Pen here. I'm having an issue with a share button that expands on hover. Everything works fine, except if you hover over it multiple times, the animation repeats as many times as you've hovered. Is there a way to prevent this from h ...

Exploring the world of CSS and designing layouts using multiple div elements

Upon reviewing this website, I must admit it is getting close to what I envision. However, being a perfectionist and new to HTML and CSS, I find myself struggling to achieve the desired outcome. The layout consists of two divs named topred and top yellow, ...

Disabling Scroll for a HTML Input Tag

My input field has a long value and is set to readonly. Although I have applied overflow-x: hidden; to it, scrolling is still possible on mobile devices. I want to disable this scroll behavior. Can anyone provide a solution? Thank you for your assistance. ...

CSS: Avoiding text overflow in a div container

Utilizing Bootstrap 4, I have a div containing lengthy text that causes overflow within the element. The issue is depicted in this image example. By introducing spaces to shorten words, the text displays correctly without overflowing. However, extended ...

Creating Eye-Catching Titles with HTML and CSS

As a beginner in HTML and CSS, I'm curious about creating an eye-catching header on a website with a different background than the rest of the page. Is it possible to achieve this effect using HTML and CSS? Apologies if this question sounds silly. T ...

Grouping and styling table data cells within a row: best practices

I am attempting to "group" a collection of cells/<td> elements within a row/<tr> in a <table> in order to apply styles to them. The code below accomplishes what I desire to some extent, but it does have its limitations: /* Issues wit ...

The content is overflowing outside the boundaries of the div, yet there is no

I am currently utilizing jQuery to dynamically load the content of a text file into a div element. However, when the content exceeds the dimensions of the div, no scroll bar is displayed. Here is the HTML structure: <!DOCTYPE html> <html lang=" ...

The section cannot be shown in a flex layout within a grid container

My goal is to showcase a grid layout containing multiple sections within a div, but I'm encountering an issue where the sections are only displaying as blocks. I am seeking assistance in making the second portion of the data appear flexed. Currently, ...

Issue with Responsive Behavior of Multi-Row Cards in Bootstrap 4

My goal is to create responsive rows of cards with some margin, but I am running into issues. When I use margin:5px; on my cards, the row overflows and they are not centered correctly. There seems to be extra space on the right side of the cards. How can I ...

"Creating a user-friendly interface design with two separate divs, each showcasing a

I am looking to create a UI/UX design that includes a logo and two menus, one for language change and one for navigation. https://i.sstatic.net/Tb6zc.png My current approach involves two div elements: 1. The first div contains the image and language men ...

I'm interested in learning the best way to insert the images from this JSON file into the corresponding div elements

I have completed developing a clone of an Instagram web page. Although I can retrieve data from the JSON file and insert it into the <img> tag, I am facing difficulty in displaying each image above its respective .below-image div with consistent spac ...

Tips for adjusting the maximum height of the column panel within the DataGrid element

I'm trying to adjust the max-height of a column panel that opens when clicking the "Columns" button in the Toolbar component used in the DataGrid. I am working with an older version of @material-ui/data-grid: "^4.0.0-alpha.8". https://i.stack.imgur.c ...

Using Font Color in Gmail HTML Emails

While working on styling an HTML email, I've encountered an unexpected issue with inline CSS in Gmail. I set the color of text in a table row using the following code: <tr style='color: #000; font-size: 14px; font-family: Verdana, serif;' ...

Is it possible to align a BootstrapVue b-form-checkbox&radio in a vertical center within Vuetify

I'm currently utilizing Vuetify as our primary framework and incorporating some Bootstrap-Vue components such as b-form-checkbox and radio. I am facing a challenge in trying to vertically center my Bootstrap-Vue checkbox and text. I have attempted se ...

Numerous websites with scroll-based navigation

I am currently building a unique website that includes scrolling in various directions without the use of a horizontal scrollbar. The design is similar to this image: https://i.stack.imgur.com/Ex2Bf.jpg. It is a one-page website where vertical scrolling ...

Configuring the color of the active page link in the navbar using Python Flask

In order to highlight the current page that the user is on, I want the link of the current page to have a different color compared to the other page links. This will help the user easily identify which page they are currently viewing. I am implementing thi ...

Interactive JQuery plugin for scrolling through thumbnails with customizable buttons

I am attempting to create a jQuery thumbnail scroller with buttons that respond to mousedown and mouseup events. I have successfully implemented the scrolling functionality, but I am facing issues when trying to refactor it into a reusable function. Below ...

Achieving Consistent Aspect Ratios with Images in Flexbox Grid

I'm attempting to utilize flexbox for arranging elements in the layout shown below: -- ------ -- | | | | |--| |--| | | | | -- ------ -- Each corner 'box' contains an image with a square aspect ratio of 1:1. The center ...