Comments (14)
Short answer: no.
Longer answer: Moving from floats to inline-block has a few minor gains (mainly no clearfix), but introduces a major setback. White-space between grid-elements is rendered, leaving you with no control over proper grid spacing. The only appropriate solution that I've seen involves adjustments to letter-spacing
- which need to be applied carefully, and in very specific ways. In the end, you've added a much more strict set of grid requirements - losing the ability to nest elements among other things.
from susy.
I was battling the whitespace thing. However, I found that setting whitespace:nowrap on the parent element of the inline-block elements solves the problem, at least in FF, Chrome, Safari. I don't really know why, since W3schools never says it collapses all of the whitespace, but it works. Do you think this is a reliable method cross-browser?
I like inline-block because it's really good for vertically lining up inputs across a row when you have different padding and margins on the inputs.
from susy.
I'd be happy to look at a demo - especially if you can re-create the AG test (on the current Susy home page, and also in the susy-next
branch test
folder. Basically just a demonstration of complex grid nesting.
Susy Next is built to handle different output modules, and I'd love to add an inline-block module if there's a good way to do it.
from susy.
I like playing with inline-block layouts too.
@ericam another advantage would be bi-directionality - when your design switches from LTR to RTL - with inline-block they just work! no overrides required.
@ariroseonline adding white-space: nowrap
is probably not a good idea - your white-space is still there, it is just the line-break that is being prevented. leaving you with spans that overflow their container.
http://codepen.io/tsi/pen/mfcpx
My favorite trick is using margin-right: -.25em
- http://codepen.io/tsi/pen/gHzdt but that still feels very hacky.
from susy.
Yeah, I'd be ok with the -.25em
approach if I trusted that number to be consistent across fonts. Maybe, now that developers often control the fonts, that just means we would need a setting to override -.25
if it wasn't working for your particular font...
from susy.
To avoid the potential inaccuracy of setting a negative margin, what about setting the containing element to font-size: 0
and resetting elements within it to font-size: 1rem
or whatever? I've had success with this and made myself a little mixin. Something like:
=zero-font-size
font-size: 0
& > *
font-size: $base-font-size
from susy.
I don't know. this -.25em
"hack" can only be trusted if we know that the white space is there.
If there is no white space, this trick will cause elements to overlap - http://codepen.io/tsi/pen/wfctv
I use this in many occasions, but I don't know if we should use this in a generic layout system such as susy, on the other hand - your suggestion about a margin parameter may actually make it very usable, allowing you to have no margin at all when there's no white-space.
I'd rather start digging into flex-box and css grids though :)
from susy.
My last comment was referring to eric's last one.
@DavidOliver - that solution is very good for handling the white-space issue but it might introduce a bigger one by breaking font-size cascading down the DOM, this might become critical when using em
s for layout widths.
from susy.
@tsi, Yes, if it were ever provided it would have to be made clear that it's best not used with em
font-sizing schemes.
from susy.
@tsi Good catch, and thanks for the codepen!
@ericam Use floats by default, and then implement an inline-block (-.25em) experimental mode with override? I wouldn't want to be a developer encountering strange behavior that needed a font related fix.
from susy.
Yeah, inline-block will never be our default. I'm willing to consider an inline-block module (or plugin) if someone builds a nice one, but I'm with @tsi — my energy is more likely to go into flex-box or grids.
from susy.
Bit late here but wanted to mention that I spent some time trying to find a reliable way to use inline-block for layout and came to the conclusion that it is not possible. See:
http://codepen.io/jbowyers/pen/pxgJk
The primary issue is, the space between elements depends on the font-family and the same font can have different spacing in different browsers and OSs. So, there is no reliable way to determine the negative margin value.
from susy.
Hope nobody minds me leaving this here, but here is a solution to fix heights in javascript since that seems to be the only option for responsive, floated grids.
(Requires jQuery but is easily ported to vanilla)
var gridCells = $(".grid-cells");
gridCells.height(Math.max.apply(null, gridCells.map(function() {
return $(this).height();
}).get()));
Any other solutions/corrections welcome.
from susy.
I wrote a little example for inline-block layout at codepen. Works in latest chrome, firefox and ie8 for me.
from susy.
Related Issues (20)
- overflowing span in susy 3 HOT 3
- Migration Guide from Susy 2 to Susy 3 HOT 8
- Susy 2 : 1200px container and 12 columns but debug image has extra column space HOT 5
- context-slice of `12 ` can not be determined based on grid-columns HOT 1
- Trying to import SVG Grid Image Plugin fails HOT 4
- Width and margin with 1/2 column spans HOT 2
- upgrade from 2.2.12 HOT 1
- Guide to use Susy3 + Node.js + Gulp ? HOT 11
- gutter() not changing with parameters HOT 4
- Which way to build a gallery ? HOT 2
- set different global Gutter base on media querie HOT 3
- gutter() errors when used with asymmetrical grid created with susy-repeat() HOT 6
- Function not found: su-span HOT 1
- span function return calc(), but not percentages. HOT 5
- Not all browsers support susy-svg-grid() with mixed units HOT 3
- No mixin named susy-breakpoint HOT 2
- @if index($span, 'last') does not work HOT 1
- Pull mixin does not work it sems... HOT 3
- Susy2+ - use sass:math for division. HOT 8
- "SassError: $number: ... is not a number" when compiling with webpack and sass-loader HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from susy.