How to collapse Foundation's xy-grid-layout cells outer gutters? - css

Trying to get my head around building Foundation's XY Grid semantically (https://foundation.zurb.com/sites/docs/xy-grid.html#building-semantically).
Think I've got most of it figured out minus a nested xy-grid-layout within a xy-grid.
My goal is to have the outer gutters on the outer cells to collapse so the Block Grid is flush with the main content cell:
Here's what I've got so far:
.fr_container {
#include xy-grid-container;
}
.fr_grid {
#include xy-grid;
background-color: $light-gray;
}
.fr_main {
#include xy-cell();
#include flex-order(2);
background-color: $medium-gray;
#include breakpoint(medium) {
#include xy-cell(9);
#include flex-order(1);
}
}
.fr_sidebar {
#include xy-cell();
#include flex-order(1);
background-color: $medium-gray;
#include breakpoint(medium) {
#include xy-cell(3);
#include flex-order(2);
}
}
.fr_full {
#include xy-cell();
}
.fr_gallery {
#include xy-grid;
#include xy-grid-layout(3, '.fr_gallery-item', true, $grid-margin-gutters, margin, right left top bottom, false);
background-color: $dark-gray;
}
.fr_gallery-item {
background-color: $black;
border: rem-calc(1) dashed $white;
color: $white;
}
The HTML:
<div class="fr_container">
<h3>Grid Container</h3>
<div class="fr_grid">
<h3 class="fr_full">Grid</h3>
<div class="fr_main">
<h3>Main Content</h3>
<h4>Block Grid</h4>
<div class="fr_gallery">
<div class="fr_gallery-item">1</div>
<div class="fr_gallery-item">2</div>
<div class="fr_gallery-item">3</div>
<div class="fr_gallery-item">4</div>
<div class="fr_gallery-item">5</div>
<div class="fr_gallery-item">6</div>
<div class="fr_gallery-item">7</div>
<div class="fr_gallery-item">8</div>
<div class="fr_gallery-item">9</div>
<div class="fr_gallery-item">10</div>
<div class="fr_gallery-item">11</div>
<div class="fr_gallery-item">12</div>
<div class="fr_gallery-item">13</div>
<div class="fr_gallery-item">14</div>
<div class="fr_gallery-item">15</div>
</div>
</div>
<div class="fr_sidebar">
<h3>Sidebar</h3>
</div>
</div>
</div>

Well Ben, to collapse the outer margin, perhaps all you need to do is add this margin override ?
.fr_container {
#include xy-grid-container;
margin: 0;
}

Related

Use nth-child on parent level only

I am trying to target all top level .dokan-form-group elements with nth-child.
As you can see, there is a wrapper in the middle called dokan-child-wrapper which has some dokan-form-group elements inside.
I don't want to target these. Only the upper most top level classes which match dokan-form-group, which is a direct descendant of .wrapper.
You can see it's targeting 4 items, but the 3rd and 4th are targeting the child elements which I don't want.
Code example:
https://codepen.io/jordanc26/pen/NWKOXKQ
HTML / SCSS Code:
<div class="wrapper">
<div class="dokan-form-group">parent-item</div>
<div class="dokan-form-group">parent-item</div>
<div class="dokan-child-wrapper">
<div class="dokan-form-group">child-item</div>
<div class="dokan-form-group">child-item</div>
<div class="dokan-form-group">child-item</div>
</div>
<div class="dokan-form-group">parent-item</div>
<div class="dokan-form-group">parent-item</div>
</div>
.
.wrapper {
.dokan-form-group {
background-color: blue;
&:nth-child(0),
&:nth-child(1),
&:nth-child(2),
&:nth-child(3) {
background-color: red;
}
}
}
Change scss to:
.wrapper {
>.dokan-form-group {
background-color: blue;
&:nth-child(1),
&:nth-child(2),
&:nth-child(3),
&:nth-child(4) {
background-color: red;
}
}
}
live demo

How to change colour of mdc-select dropdown arrow?

I'm trying to change the default purple colour of the dropdown arrow in an mdc-select:
None of the sass mixins seem to do it.
How is it done?
Here is what I have tried so far:
HTML
<div class="mdc-select mdc-select--outlined">
<input type="hidden" name="enhanced-select">
<i class="mdc-select__dropdown-icon"></i>
<div class="mdc-select__selected-text" class="mdc-select__selected-text" role="button" aria-haspopup="listbox" aria-labelledby="demo-label"></div>
<div class="mdc-select__menu mdc-menu mdc-menu-surface">
<ul class="mdc-list">
<li class="mdc-list-item" data-value="41" role="option">41</li>
<li class="mdc-list-item" data-value="42" role="option">42</li>
<li class="mdc-list-item" data-value="43" role="option">43</li>
</ul>
</div>
<div class="mdc-notched-outline">
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label class="mdc-floating-label">Answer to Life</label>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
SCSS
#import "#material/list/mdc-list";
#import "#material/menu-surface/mdc-menu-surface";
#import "#material/menu/mdc-menu";
#import "#material/select/mdc-select";
.mdc-select {
#include mdc-select-ink-color(red);
// #include mdc-select-container-fill-color(red);
#include mdc-select-label-color(red);
#include mdc-select-focused-label-color(red);
#include mdc-select-bottom-line-color(red);
#include mdc-select-focused-bottom-line-color(red);
#include mdc-select-hover-bottom-line-color(red);
#include mdc-select-outline-color(red);
#include mdc-select-focused-outline-color(red);
#include mdc-select-hover-outline-color(red);
#include mdc-select-icon-color(red);
}
TS
import { MDCSelect } from '#material/select';
const select = new MDCSelect(document.querySelector('.mdc-select'));
this is not a icon or font this arrow is a background image of class .mdc-select--focused .mdc-select__dropdown-icon. you can change the image color by using filter css property.
filter: hue-rotate(60deg);
apply this css to your custom css for the class .mdc-select--focused .mdc-select__dropdown-icon it will work.
Thank You.
I managed to theme it by using an MDC internal Sass mixin: mdc-select-dd-arrow-svg-bg_. An example is:
.mdc-select .mdc-select__dropdown-icon {
#include mdc-select-dd-arrow-svg-bg_(COLOR, 1);
}
where COLOR is an MDC theme property (e.g. 'secondary') or an HTML color (e.g. #ff0000). It cannot be a var because, as pointed by #KuldipKoradia, an SVG is generated at compilation time.
The easiest and simplest way is to hide the SVG and just create your own dropdown arrow through CSS (no HTML changes needed). Then you can easily change the color as often as you need to:
.mdc-select__dropdown-icon{
background: none;
width: 0;
height: 0;
bottom: 24px;
right: 10px;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #333333;
}
.mdc-select--activated .mdc-select__dropdown-icon,
.mdc-select--focused .mdc-select__dropdown-icon {
border-top: 5px solid #FF0000;
}

Responsive Image in Neat 2.0

Is there a recommended way to get an image to be 100% of the height of a column in Neat based on the size that the text makes the column? I've attached an example of what I'm trying to accomplish below.
I'm trying to make the image fill the 1/3 column it is placed in with object-fit: cover, the problem is that because the height of the container isn't set, it doesn't know what to fit the image to.
Image With No Height Set
If I put the image in a div with display: flex; and height:100%, the height gets set to the height of the image, when I want it to get set to the height of the parent, which is the grid-container that has the two columns in it.
Image With 100% Height Set
What I'm trying to accomplish is have a responsive image that constantly fills the space of its column to match the height of the text in the next column.
I should note that I'm trying to accomplish this without setting a specific height for the parent container such as height:200px, I want the height to be fluid to the content in it.
HTML Code:
<section class="image-block" style="background: #5777e0; color:#fff;">
<div class="one-thirds-column-full no-padding third-image-box">
<div class="flex">
<img src="https://unsplash.it/1600/1200?image=148" />
</div>
</div>
<div class="two-thirds-column-full">
<div class="text">
<h2>1/3 Image on Left with 2/3 Text on Right</h2>
<p>
The path of the righteous man is beset on all sides by the iniquities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's
keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy My brothers. And you will know My name is the Lord when I lay My vengeance upon thee.
</p>
</div>
</div>
</section>
CSS:
section {
#include grid-container;
#include grid-media($neat-small) {
#include grid-container($neat-small);
}
#include grid-media($neat-medium) {
#include grid-container($neat-medium);
}
#include grid-media($neat-large) {
#include grid-container($neat-large);
}
#include grid-media($neat-larger) {
#include grid-container($neat-larger);
}
#include grid-media($neat-super) {
#include grid-container($neat-super);
}
}
.one-thirds-column-full {
#include grid-column(1, $neat-grid-full);
padding:1em;
#include grid-media($neat-medium-full) {
#include grid-column(2);
}
#include grid-media($neat-large-full) {
#include grid-column(4);
}
}
.two-thirds-column-full {
#include grid-column(1, $neat-grid-full);
padding:1em;
#include grid-media($neat-small-full) {
#include grid-column(2);
}
#include grid-media($neat-medium-full) {
#include grid-column(4);
}
#include grid-media($neat-large-full) {
#include grid-column(8);
}
}
.image-block{
background: #fff;
text-align: left;
.third-image-box{
height:auto;
}
.half-image-box{
height:auto;
}
.flex{
display:flex;
height:100%;
}
img{
height:auto !important;
object-fit: cover;
}
}
.text{
max-width:$max-text-width;
}
There is a bug in the documentation and grid-container does not require or need access to the grid so you can shorten the first part to ⤵
section {
#include grid-container;
I don't think you need that much markup in the html around the img. You may be able to just do
<section class="image-block">
<img src="https://unsplash.it/1600/1200?image=148" class="one-thirds-column-full">
<div class="two-thirds-column-full">
…
</div>
</section>
and then the css would be like…
.image-block{
align-items: stretch;
display: flex;
}
align-items: stretch will cause both objects to fill the vertical space. The rest is up to object-fit: cover, etc

How to select only first two children of a parent in a mixin with nth-child?, not every first and second

How to select only first two children of a parent (not every first and every second child). In a .scss mixin using nth:child selector?
Here is my code and it doesn't work because it selects every second div. But I need to select only col_l as a :nth-child(1) and col_r as a :nth-child(2).
html:
<section id="section" class="clearfix">
<div class="col_l"> <!-- this is div:nth-child(1) -->
<div class="title">
Left col
</div>
<div></div>
<div></div> <!-- this div is also selected as a :nth-child(2), but it is wrong -->
</div>
<div class="col_r"> <!-- this is div:nth-child(2) -->
<div class="title">
Right Col
</div>
</div>
</section>
.scss:
#mixin two-col($width-left, $width-right) {
#include clearfix;
div:nth-child(1) {
float: left;
width: $width-left;
}
div:nth-child(2) {
float: right;
width: $width-right;
}
}
#section {
#include two-col(714px, 237px);
background-color: #749675;
.col_l { }
.col-r { }
}
How to select only the first and only the second divs? Not every.
You need to add the child combinator > to the selectors in your mixin to ensure you actually select just the children of #section and not any further descendants:
#mixin two-col($width-left, $width-right) {
#include clearfix;
> div:nth-child(1) {
float: left;
width: $width-left;
}
> div:nth-child(2) {
float: right;
width: $width-right;
}
}

Bourbon/Neat: Reset margin and let nested divs span the whole width

I am new to Bourbon/Neat. I have a question concerning nesting: I want the red boxes fill the whole width, without a gutter between them. When using "#include omega" on them, the first box removes its margin-right, but the right box has still the margin and doesn't adjust its width.
Can u tell me how I can make them span the whole parent box without any margin between them?
Here's a demo: http://wuergeengel.net.dd13736.kasserver.com/
Here's my markup:
<div class="container">
<div class="box box-left"></div>
<div class="box box-right">
<div class="box-red-left nested"></div>
<div class="box-red-right nested"></div>
</div>
</div>
Here are my styles:
.container
{
#include outer-container;
}
.box
{
border: 1px solid black;
height: 500px;
}
.box-left
{
#extend .box;
#include span-columns(4);
}
.box-right
{
#extend .box;
#include span-columns(8);
.nested
{
border: 1px solid red;
height: 400px;
&.box-red-left
{
#extend .nested;
#include span-columns(3 of 8);
#include omega;
}
&.box-red-right
{
#extend .nested;
#include span-columns(5 of 8);
#include omega;
}
}
}
Or this:
#include span-columns(5 of 8, block-collapse)
See:
http://neat.bourbon.io/docs/#span-columns
There are a couple ways that you can do this.
Use Neat's table display layout. eg: #include span-columns(5 of 8, table);
Use Neat's underlying flex-grid and flex-gutter functions. eg:
width: flex-grid(5, 8) + flex-gutter(8);
float: left;

Resources