I have implemented layout calculation with the help of JS, that calculates each column and fills in each column with elements.
The basic idea is following:
calculate total height of all elements
split items into equal columns according to the height of each element (columns count depends on screen width)
items order does matter
"equal columns" means not exactly equal but approximately.
JS layout
I know that flexbox can fill in each column until flexbox reaches height limit for column, then flexbox starts filling in next column...
But I want "equal columns"...
My question is not about Why is the two p-tags not beside each other when the screen is wide? or Horizontal masonry layout with flexbox CSS only [duplicate], maybe something like How to split a nested navigation into columns with almost equal heights but without JS and without "column fill in limitation".
Is it possible to implement such behavior with flexbox and without JavaScript?
Related
I want to use bootstrap's well component on a horizontal form.
Most rows of the form only have one or two fields in a set of columns, and I am specifying the width of each column.
I would like to style some of the of rows in a well, but I don't want to have the well go across the entire screen, because it looks weird to have so much extra space to the right of the fields. I only want to style the maximum width of the columns in the rows.
If enclose the grid within a div of a set size, then all of the controls' sizes and positioning are affected.
Is there anyway to style a row this way?
Is there a way to create a div that has the right width, and position underneath the actual rows?
I need to have one 740px column for the content and one 320px for the sidebar so the container must be 1060px.
Is there anyway to get this exact grid size in bootstrap ?
I know I can customize there http://getbootstrap.com/customize/ but i dont know the exact numbers for get it.
You won't really get this "exact grid size in bootstrap" since the Bootstrap grid uses percentage-based columns widths.
The simplest approach is to override the Bootstrap css to set a specific width on those columns, which will (of course) result in the columns no longer being responsive. You can still use the responsive grid nested inside the outer columns, and other Bootstrap features.
2-columns fixed width layout: http://bootply.com/B9ti0Rjer1
You could optionally use a media query to apply the fixed widths on larger screens only: http://bootply.com/5Kv1z1XCQK
I want to utilize CSS3 Columns around my site as it on wide pages provides a better UX for the users. However if I use CSS3 Columns, sometimes the left column is full (lets say 20 lines of text) and the right side only have2 lines of text. Can I with pure css3 (maybe Flexbox) make it have equal amount of content? Or do I need JS to fix this?
Beaware I'm not talking about equal height, but equal amount of content :)
You'll need to specify a height property.
From the Mozilla docs:
The CSS3 Column specification requires that the column heights must be
balanced: that is, the browser automatically sets the maximum column
height so that the heights of the content in each column are
approximately equal.
However, in some situations it is also useful to set the maximum
height of the columns explicitly, and then lay out content starting at
the first column and creating as many columns as necessary, possibly
overflowing to the right. Therefore, if the height is constrained, by
setting the CSS height or max-height properties on a multi-column
block, each column is allowed to grow to that height and no further
before adding new column. This mode is also much more efficient for
layout.
Sorry it was a padding-bottom which messed it up. When I remove that it spreads out nicely. Strange!
I'm trying to achieve the Pinterest layout with entities of variable width and height. So not only the height is variable in the given layout.
The layout from above is achieved with flexbox (row wrap) on the parent. I would like to move column 31 to be right under column 1, instead of where it is right now, and column 32 to be right under column 2, and so on. I think it has something to do with the cross-axis property of flexbox, but I could not find the right property.
This is a node webkit prototype, so if it works in webkit, then this is great. Any ideas?
Another idea that I am considering is using a css grid, but I have to define a finite number of grid rows and columns, while this layout should be flexible, so making the window wider should increase the number of columns.
I am working on a Flex mobile project and am using a TileLayout to layout a bunch of groups. The problem is, if any text in one of the groups spans several lines, ALL tiles get resized to the same height. I need the tile width to be the same for all tiles, but I want the tile height to be the tallest only on each row. Thanks for the help.
I found a work-around for this. I had to write a custom layout that calculates the number of columns and the max height for each row.