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;
Related
While I know you can't write variables like
root: {
--aic: align-items:center;;
}
Is there anyway to get round this, by combining the various parts seperately? The obvious obstical here is the requirement of the colon inside the variable.
i.e.
root: {
--ai: align-items:;
--center: center;
--aic:
var(--ai)
var(--center);
}
.myclass {var(--aic);}
I would suggest you to switch to SCSS and use a #mixin. Read more about it here.
Here's a live demo.
HTML:
<div id="test">TEST</div>
SCSS:
:root {
--text_color: red;
--background_color: gold;
}
#mixin my_mixin {
color: var(--text_color);
background-color: var(--background_color);
}
#test {
#include my_mixin;
}
Based on my comment on your question, you can use classes to achieve something similar. But you can't use custom properties as CSS properties, only values -- it's the same as saying for example margin: margin: var(--customMargin);;
/* Layout unrelated to answer */
div { border: 1px solid black; color: white }
.varText { background-color: red }
.varPad { background-color: blue }
.varText.varPad { background-color: green }
/* Answer */
:root { --size: 1rem }
.varText { font-size: var(--size) }
.varPad { padding: var(--size) }
<div class="varText">
Size Text only to root variable
</div>
<div class="varText" style="--size: 2rem">
Size Text only to inline variable
</div>
<div class="varPad">
Size Padding only to root variable
</div>
<div class="varPad" style="--size: 2rem">
Size Padding only to inline variable
</div>
<div class="varText varPad">
Size Text and Padding to root variable
</div>
<div class="varText varPad" style="--size: 2rem">
Size Text and Padding to inline variable
</div>
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;
}
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
I'm using a custom 12-column grid and given a row like:
<div class="row">
<div id="the-pink" class="lg-6 md-12 sm-12"><!-- content --></div>
<div id="the-violet" class="lg-6 md-12 sm-12"><!-- content --></div>
</div>
I'm trying to get this behaviour: On medium and small devices each block will be 12-columns width but, by default, #the-violet will fall below #the-pink. I'd like the opposite, that's #the-violet above #the-pink.
My current (simplified) SCCS is:
.row {
#include clearfix;
[class*="lg-"],
[class*="md-"],
[class*="sm-"] {
float: left;
}
}
.lg-6 {
width: 50%;
}
.md-12 {
#include respond-to("medium") {
width: 100%;
}
}
.sm-12 {
#include respond-to("small") {
width: 100%;
}
}
I'm assuming clearfix and respond-to mixins are well-known.
I've made and approach with fixed height giving my row a class named reversed like (Fiddle):
.reversed {
position: relative;
#include respond-to("small" "medium") {
.sm-12,
.md-12 {
position: absolute;
top: 0;
&::first-child {
top: 200px;
}
}
}
}
But, I'd like to know if anyone has faced this need before and has another approach to solve it in a clean way (without fixing height).
You could use float: right on them and write them in the reverse order in the HTML.
I'm having problem with integration of zen-grids into drupal. I have installed sass and compass and using them. Then I created a content type with 3 fields. That give me structure in html like that:
<article class="node-1 node node-layout1 node-promoted view-mode-full clearfix" typeof="sioc:Item foaf:Document" about="/node/1">
<div class="field field-name-field-topleft field-type-text-long field-label-above">
<div class="field field-name-field-topmid field-type-text-long field-label-above">
<div class="field field-name-field-topright field-type-text-long field-label-above">
</article>
Then I tryied to use zen grids to create layout like that:
topleft___________topmid_______________topright
So I used that code:
$zen-column-count: 5; // Set the total number of columns in the grid.
.node-layout1{
max-width:1200px;
#include zen-grid-container; // Apply this mixin to the container.
}
.field-name-field-topleft {
#include zen-grid-item(2, 1);
}
.field-name-field-topmid {
#include zen-grid-item(1, 2);
}
.field-name-field-topright {
#include zen-grid-item(2, 3);
}
All works kinda ok I get all 3 elements in line but their widths and offsets are way too large, topmid starts where topright should finish, so my page is way too large after that.
Here is css i get generated from compass for all 3 elements:
.field-name-field-topleft {
float: left;
margin-left: 0;
margin-right: -200%;
width: 200%;
}
.field-name-field-topmid {
float: left;
margin-left: 100%;
margin-right: -200%;
width: 100%;
}
.field-name-field-topright {
float: left;
margin-left: 200%;
margin-right: -400%;
width: 200%;
}
I found out that the problem is in
$zen-column-count: 5;
not getting applied, it was set at start to 1 and seems that I can't change it.
It sounds like a problem with compass 1.0, as documented here:
https://github.com/JohnAlbin/zen-grids/issues/68
A fix is to add $zen-float-direction, $zen-column-count to your zen-grid-item call, i.e.
#include zen-grid-item(2, 1, $zen-float-direction, $zen-column-count);
use !global at the end of "$zen-column-count: 5" fixed it for me. it seems you must force zen to use new variable.
$zen-column-count: 5 !global;
https://www.drupal.org/node/2346291#comment-9475791