Image matrices defined in Susy aren't lining up properly - susy-compass

I think I managed to solve most of my starting problems with Susy. The only odd thing left I can't figure out is why it behaves the way it does when creating an image matrix.
Here's my setup:
$total-columns: 24;
$column-width: 6%;
$gutter-width: 1%;
$grid-padding: 0;
$container-style: magic;
Here's the HTML code:
<section name="Projekte" class="projects" role="main">
<hgroup>
<h1 class="maintitle">Unsere Projekte</h1>
<h2 class="subtitle">Subtitle</h2>
</hgroup>
<ul class="moodlegrid">
<li><img title="Projekte1" src="img/projekte.jpg" /></li>
<li><img title="Projekte2" src="img/projekte.jpg" /></li>
<li><img title="Projekte3" src="img/projekte.jpg" /></li>
<li><img title="Projekte4" src="img/projekte.jpg" /></li>
<li><img title="Projekte5" src="img/projekte.jpg" /></li>
<li><img title="Projekte6" src="img/projekte.jpg" /></li>
<li><img title="Projekte7" src="img/projekte.jpg" /></li>
<li><img title="Projekte8" src="img/projekte.jpg" /></li>
<li><img title="Projekte9" src="img/projekte.jpg" /></li>
</ul>
<div class="proper"></div>
</section><!-- end section -->
This should be a 3x3 matrix of images and elsewhere on the page there should be a 7x4 matrix of images, but both act odd. Both don't respect that there are 3 margin columns at both sides as well as their position.
The supposed 7x4 matrix looks like this, and
the supposed 3x3 matrix looks like this.
Here's the CSS code:
section {
#include boxcolor($section-container);
width: 100%;
#include no-bullets;
#include box-shadow(black 2px 2px 10px);
margin-bottom: 2*1.5em;
padding-bottom: 2*1.5em;
clear: both;
}
.customers li {
#include squish(3,3);
#include span-columns(2,18);
#include nth-omega(7n);
margin-left:0;
}
.moodlegrid li{
#include squish(3,3);
#include span-columns(6,18);
#include nth-omega(3n);
margin-left:0;
}
That's it for the moment. Has anybody a slightest idea why Susy is behaving like this? Especially on the 3x3 matrix, where everything should basically fit in: 6 + 3*6 equals to the number of columns I have set. Confusing somehow.

You don't want to squish the same elements that you are using for you columns. You want to squish the parent. Currently, squish is not doing anything, because you override it with span-columns.
.customers {
#include squish(3,3);
li {
#include span-columns(2,18);
#include nth-omega(7n);
}
}
.moodlegrid
#include squish(3,3);
li{
#include span-columns(6,18);
#include nth-omega(3n);
}
}

Related

Pinterest like Masonry Layout [duplicate]

This is, in effect, the Pinterest layout. However, the solutions found online are wrapped in columns, which means the container inadvertently grows horizontally. That is not the Pinterest layout, and it does not work well with dynamically-loaded content.
What I want to do is have a bunch of images of fixed width and asymmetrical height, laid out horizontally but wrapping in a new row when the limits of the fixed-width container are met:
Can flexbox do this, or do I have to resort to a JS solution like Masonry?
Flexbox is a "1-dimensional" layout system: It can align items along horizontal OR vertical lines.
A true grid system is "2-dimensional": It can align items along horizontal AND vertical lines. In other words, cells can span across columns and rows, which flexbox cannot do.
This is why flexbox has a limited capacity for building grids. It's also a reason why the W3C has developed another CSS3 technology, Grid Layout (see below).
In a flex container with flex-flow: row wrap, flex items must wrap to new rows.
This means that a flex item cannot wrap under another item in the same row.
Notice above how div #3 wraps below div #1, creating a new row. It cannot wrap beneath div #2.
As a result, when items aren't the tallest in the row, white space remains, creating unsightly gaps.
image credit: Jefree Sujit
column wrap Solution
If you switch to flex-flow: column wrap, flex items will stack vertically and a grid-like layout is more attainable. However, a column-direction container has three potential problems right off the bat:
It expands the container horizontally, not vertically (like the Pinterest layout).
It requires the container to have a fixed height, so the items know where to wrap.
As of this writing, it has a deficiency in all major browsers where the container doesn't expand to accommodate additional columns.
As a result, a column-direction container may not be feasible in many cases.
Other Solutions
Add containers
In the first two images above, consider wrapping items 2 and 3 in a separate container. This new container can be a sibling to item 1. Done.
Here's a detailed example: Calculator keypad layout with flexbox
One downside worth highlighting: If you're wanting to use the order property to re-arrange your layout (such as in media queries), this method may eliminate that option.
Desandro Masonry
Masonry is a JavaScript grid layout library. It
works by placing elements in optimal position based on available
vertical space, sort of like a mason fitting stones in a wall.
source: http://masonry.desandro.com/
How to Build a Site that Works Like Pinterest
[Pinterest] really is a cool site, but what I find interesting is how these pinboards are laid out... So the purpose of this tutorial is to re-create this responsive block effect ourselves...
source: https://benholland.me/javascript/2012/02/20/how-to-build-a-site-that-works-like-pinterest.html
CSS Grid Layout Module Level 1
This CSS module defines a two-dimensional grid-based layout system, optimized for user interface design. In the grid layout model, the children of a grid container can be positioned into arbitrary slots in a predefined flexible or fixed-size layout grid.
source: https://drafts.csswg.org/css-grid/
Grid Layout example: CSS-only masonry layout but with elements ordered horizontally
What you want can be achieved in 3 2 ways, CSS wise:
flexbox:
=
.parent {
display: flex;
flex-direction: column;
flex-wrap: wrap;
max-width: {max-width-of-container} /* normally 100%, in a relative container */
min-height: {min-height-of-container}; /* i'd use vh here */
}
.child {
width: {column-width};
display: block;
}
CSS columns
=
(this solution has the very neat advantage of built-in column-span - pretty handy for titles). The disadvantage is ordering items in columns (first column contains first third of the items and so on...). I made a jsFiddle for this.
.parent {
-webkit-columns: {column width} {number of columns}; /* Chrome, Safari, Opera */
-moz-columns: {column width} {number of columns}; /* Firefox */
columns: {column width} {number of columns};
}
.child {
width: {column width};
}
/* where {column width} is usually fixed size
* and {number of columns} is the maximum number of columns.
* Additionally, to avoid breaks inside your elements, you want to add:
*/
.child {
display: inline-block;
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid-column;
}
Masonry plugin
absolute positioning after calculating rendered item sizes, via JavaScript (masonry plugin).
You can achieve the masonry effect as per your screenshot, but you've set the height of the outer div dynamically
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
.item-list {
max-width: 400px;
border: 1px solid red;
display: -ms-flexbox;
-ms-flex-direction: column;
-ms-flex-wrap: wrap;
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 100vw;
}
.item-list__item {
border: 1px solid green;
width: 50%;
}
<div class="item-list" >
<div class="item-list__item">
Is we miles ready he might going. Own books built put civil fully blind fanny. Projection appearance at of admiration no. As he totally cousins warrant besides ashamed do. Therefore by applauded acuteness supported affection it. Except had sex limits
county enough the figure former add. Do sang my he next mr soon. It merely waited do unable.
</div>
<div class="item-list__item">
Is we miles ready he might going. Own books built put civil fully blind fanny. Projection appearance at of admiration no. As he totally cousins warrant besides ashamed do.
</div>
<div class="item-list__item">
Is we miles ready he might going. Own books built put civil fully blind fanny. Projection appearance at of admiration no. As he totally cousins warrant besides ashamed do. Therefore by applauded acuteness supported affection it. Except had sex limits
</div>
<div class="item-list__item">
Is we miles ready he might going. Own books built put civil fully blind fanny. Projection appearance at of admiration no. As he totally cousins warrant besides ashamed do.
</div>
<div class="item-list__item">
Is we miles ready he might going. Own books built put civil fully blind fanny. Projection appearance at of admiration no. As he totally cousins warrant besides ashamed do. Therefore by applauded acuteness supported affection it. Except had sex limits
</div>
</div>
Instead of flexbox, I recommend to use columns for grids like this. As you can see, the spacing on the bottom images can be better, but for a native CSS solution I think it's pretty neat. No more JS:
.container {
max-width: 900px;
width: 100%;
margin: 0 auto;
}
ul {
margin: 0;
padding: 0;
}
ul li {
list-style: none;
font-size: 0;
}
.portfolio ul {
-moz-column-count: 4;
-webkit-column-count: 4;
column-count: 4;
-moz-column-gap: 3px;
-webkit-column-gap: 3px;
column-gap: 3px;
}
.portfolio ul:hover img {
opacity: 0.3;
}
.portfolio ul:hover img:hover {
opacity: 1;
}
.portfolio ul li {
margin-bottom: 3px;
}
.portfolio ul li img {
max-width: 100%;
transition: 0.8s opacity;
}
<section class="container portfolio">
<ul>
<li><img src="http://lantosistvan.com/temp/freecodecamp/IMG_2959-1400px.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/lantosistvan-portfolio-010.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/IMG_6188-dng-k.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/20151220-csaladi-peregi-046-k.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/20151230-csalad-szalai-0194-k.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/lantosistvan-portfolio-001(1).jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528171819-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528171829-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528171938-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528171953-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528194754-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528184948-portfolio.jpg" alt="" /></li>
</ul>
</section>
the column approach seems a good compromise if you set column-width via vmin or vmax units and drop column-count (first snippet) , display:grid and vmin is also an option for the futur (second snippet).
snippet inspired from #Lanti answer.
test demo with vmin
.container {
}
ul {
margin: 0;
padding: 0;
}
ul li {
list-style: none;
font-size: 0;
}
.portfolio ul {
-webkit-column-width:50vmin;
-moz-column-width:50vmin;
column-width:50vmin;
-webkit-column-fill:balance;
-moz-column-fill:balance;
column-fill:balance;
-webkit-column-gap: 3px;
-moz-column-gap: 3px;
column-gap: 3px;
}
.portfolio ul:hover img {
opacity: 0.3;
}
.portfolio ul:hover img:hover {
opacity: 1;
}
.portfolio ul li {
margin-bottom: 3px;
}
.portfolio ul li img {
max-width: 100%;
transition: 0.8s opacity;
}
<section class="container portfolio">
<ul>
<li><img src="http://lantosistvan.com/temp/freecodecamp/IMG_2959-1400px.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/lantosistvan-portfolio-010.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/IMG_6188-dng-k.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/20151220-csaladi-peregi-046-k.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/20151230-csalad-szalai-0194-k.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/lantosistvan-portfolio-001(1).jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528171819-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528171829-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528171938-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528171953-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528194754-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528184948-portfolio.jpg" alt="" /></li>
</ul>
</section>
a link among others https://web-design-weekly.com/2014/11/18/viewport-units-vw-vh-vmin-vmax/
display:grid coud make it also easy with auto-fill but will require to set a span value to tallest image so rows and columns can inbricate
.container {}
ul {
margin: 0;
padding: 0;
}
ul li {
list-style: none;
font-size: 0;
}
.portfolio ul {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(50vmin, 1fr));
grid-gap: 5px;
grid-auto-rows: minmax(10px, 1fr);
grid-auto-flow: dense;
}
.portfolio ul:hover img {
opacity: 0.3;
}
.portfolio ul:hover img:hover {
opacity: 1;
}
.portfolio ul li {
margin-bottom: 3px;
}
.portfolio ul li img {
max-width: 100%;
transition: 0.8s opacity;
}
li {
border: solid blue;
grid-row-end: span 1;
display: flex;
align-items: center;
background: lightgray;
}
li:nth-child(1),
li:nth-child(3),
li:nth-child(6),
li:nth-child(7),
li:nth-child(8),
li:nth-child(9),
li:nth-child(10),
li:nth-child(11) {
border: solid red;
grid-row-end: span 2
}
<section class="container portfolio">
<ul>
<li><img src="http://lantosistvan.com/temp/freecodecamp/IMG_2959-1400px.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/lantosistvan-portfolio-010.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/IMG_6188-dng-k.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/20151220-csaladi-peregi-046-k.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/20151230-csalad-szalai-0194-k.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/lantosistvan-portfolio-001(1).jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528171819-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528171829-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528171938-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528171953-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528194754-portfolio.jpg" alt="" /></li>
<li><img src="http://lantosistvan.com/temp/freecodecamp/160528184948-portfolio.jpg" alt="" /></li>
</ul>
</section>
you can see https://css-tricks.com/snippets/css/complete-guide-grid/

bootstrap social media icons above menu

I am using Bootstrap and trying to get the social media icons above the menu - so far I have:
What I am aiming for is something like this:
So the image is at the end - and the menu items are still responsive.
The code I have so far is :
<header class="navbar navbar-inverse header-outer" role="banner">
<div class="container">
<img src="logo1.png " alt="Image" id="logo" class="img-responsive pull-left" />
<div class="social_media">
<ul class="nav navbar-nav pull-left padding-top nextline">
<li><img src="facebook.png" /></li>
<li><img src="twitter.png" /></li>
<li><img src="linkdin.png" /></li>
<li><img src="instagram.png" /></li>
</ul>
</div>
<div class="pull-left padding-top">
<ul class="nav navbar-nav navbar-right">
<li>Sign Up</li>
<li>Sign In</li>
<li>About</li>
</ul>
</div>
<button style="position:relative; left:0;">CONTACT WITH US</button>
</div>
</header>
and the CSS is:
<style>
.social_media {
width: 100%;
}
.navbar{ background:#ffffff; border:none;}
.nextline {
width:80%;
border-bottom : 1px solid #000000;
}
</style>
Has anyone done anything like this???
You have to put another div around the lower part to group it. Only then you can assure that the contact button can be inline with your underline of the social media section, as you set the width to the same as your nextline class. This way you get a container for the part below the line, that has the same width, and you can align the button as you want.
So your code should look like
<div class="pull-left padding-top" style="width:80%">
<div class="pull-left padding-top">
<ul class="nav navbar-nav navbar-right">
<li>Sign Up</li>
<li>Sign In</li>
<li>About</li>
</ul>
</div>
<button class="pull-right padding-top">CONTACT WITH US</button>
</div>
A simple jsfiddle for whole code
https://jsfiddle.net/87xz8q9x/5/
Hope this helps

setting twig value depending on current device

Using bootstrap( 3.3.6.) and twig( 1.24.0 ) is there is a way to set different value to some twig variable, depending on
current device?
I suppose something like
<div class="visible-xs">{% set images_in_1_row = 1 %}</div>
<div class="visible-sm">{% set images_in_1_row = 2 %}</div>
<div class="visible-md">{% set images_in_1_row = 3 %}</div>
<div class="visible-lg">{% set images_in_1_row = 4 %}</div>
and if current device is ipad, I suppose images_in_1_row has value "2", but not "4"...
Thanks!
Just a small snippet how you should do this with CSS:
* {
margin : 0;
padding : 0;
}
#container {
width : 1000px;
background : #DFF2BF;
min-height : 100vh;
border-left : 1px solid #4f8a10;
border-right : 1px solid #4f8a10;
margin: 0 auto;
}
.clear {
clear : both;
}
ul {
list-style : none;
padding : 25px;
}
ul li {
width :300px;
margin : 0 25px 25px 0;
float : left;
}
ul li img {
width: 100%;
}
ul li:nth-of-type(3n) {
margin-right: 0;
}
#media only screen and (min-width: 768px) and (max-width: 999px) {
#container {
width : 768px;
}
ul li {
width: 345px;
}
ul li:nth-of-type(2n) {
margin-right: 0;
}
ul li:nth-of-type(2n+1) {
margin-right : 25px;
}
}
#media only screen and (min-width: 480px) and (max-width: 767px) {
#container {
width : 480px;
}
ul li {
width : 430px;
margin-right 0;
}
}
#media only screen and (max-width: 479px) {
#container {
width : 320px;
}
ul li {
width : 280px;
margin-right 0;
}
}
<!DOCTYPE html>
<html>
<head>
<title>Mediaqueries Gallery</title>
</head>
<body>
<div id="container">
<ul>
<li><img src="http://www.bekijksite.be/test/placeholder.png" /></li>
<li><img src="http://www.bekijksite.be/test/placeholder.png" /></li>
<li><img src="http://www.bekijksite.be/test/placeholder.png" /></li>
<li><img src="http://www.bekijksite.be/test/placeholder.png" /></li>
<li><img src="http://www.bekijksite.be/test/placeholder.png" /></li>
<li><img src="http://www.bekijksite.be/test/placeholder.png" /></li>
<li><img src="http://www.bekijksite.be/test/placeholder.png" /></li>
<li><img src="http://www.bekijksite.be/test/placeholder.png" /></li>
<li><img src="http://www.bekijksite.be/test/placeholder.png" /></li>
<li><img src="http://www.bekijksite.be/test/placeholder.png" /></li>
<li><img src="http://www.bekijksite.be/test/placeholder.png" /></li>
</ul>
<div class="clear"></div>
</div>
</body>
</html>

Bootstrap layout - not centered and bad zooming

i am now working for several days now on a header for our project. Everything is ok - but the layout not.
In my Layout I have on the left a logo, in the middle a navbar, and on the right Login/Logout/Register links.
My Problem is, that I can't center the navbar as I want, if I try, then it is only for my display resolution ok and e.g. if I zoom in or out, it is going bad.
This is also very nice, but I don't know how to do it.
I would be really glad if somebody could help me.
Thanks in advance.
HTML
<body>
<div class="row">
<div class="span3">
<img src="/resources/img/logos/bb_logotype_blue_110.png" />
</div>
<div class="span6">
<!-- NavBar -->
<ul id="navbar">
<li>Product</li>
<li>Support</li>
<li>Blog</li>
<li>About</li>
</ul>
</div>
<div class="span3"></div>
<div id="nav-account" class="nav-collapse pull-right">
<ul class="nav">
<li><a id="register" href="/register">Register</a></li>
<li><a id="login" href="/login/form">Login</a></li>
</ul>
</div>
</div>
</div>
<div class="container" style="margin-top:3em">
<h1 id="title"></h1>
... some stuff ...
</div>
CSS
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
#navbar li
{
display: inline;
border-right: 2px solid black;
padding-left: 20px;
padding-right: 20px;
font-weight: bold;
font-size: 16pt;
}
#navbar li:last-child
{
border-right: 0;
padding-right: 0;
}
</style>
In bootstrap, if you place elements inside a <container> block, they will be automatically centered and resized to fit in the grid layout. Perhaps that is what you are looking for.

Bootstrap: fluid layout with no external margin

if i have:
<div class="container-fluid">
<div class="row-fluid">
<div class="span8">
Some Element....
</div>
<div class="span4">
Other Element
</div>
</div>
</div>
With this code i have some margin from left and right window borders. How can eliminate these margins?
Thanks for your support
If i understand your question correctly, I believe you want this:
.container-fluid {
padding: 0px;
}
Also if you are using responsive bootstrap you will also want this:
#media (max-width: 797px) {
body {
padding-left: 0px;
padding-right: 0px;
}
}
Edit: here is a js fiddle.
The effect you are seeing is because of the container’s padding.
You can change the container’s default padding with the built-in Bootstrap 4 spacing utility classes.
To remove the padding, add p-0 to the container:
<div class="container-fluid p-0">
<div class="row">
<div class="col-8">
Some Element....
</div>
<div class="col-4">
Other Element
</div>
</div>
</div>
Using the built-in utility classes has the benefit of keeping your CSS lean and it also does not modify the default container-fluid class definition.

Resources