Responsive design that manipulates multi-column content - css

I would like to implement a UI with 1 or 2 columns depending on screen/device width. I'm using Ajax to load data into these two columns and append it according to those item heights so both columns take approx. the same amount of vertical space.
Everything's ok if user keeps their browser window size the same at all time, because initial loading will either fill 1 or 2 columns. But the problem arises when the user resizes their window I have to consolidate all content accordingly:
smaller size hides column 2 and all it's items should be inserted into columns 1 in correct order
larger size displays both columns and takes some content from column 1 and puts it into column 2
I can use Javascript to do this, but I was wondering whether it's possible to do the same in CSS only way?
An example of this is Google+ that works with 1..3 columns depending on content width.

I came up with a solution of my own
It is possible using CSS only but maybe not feasible
Feasible in terms of resource consumption. When adding items on the page, always put all of them in column 1 adding an additional CSS class to those that you also position in column 2.
Responsive media queries will then either:
Hide column 2 and show those additional items in column 1 (based on CSS class).
Show column 2 and hide items with appropriate CSS class in column 1
That's the only way to avoid Javascript processing when user resizes their browser window.
The problem
The only problem there is to this functionality is when you display lots of items, because your DOM will have on average 50% more nodes as approximately half of those items will be duplicated across the page (even though only one copy of those duplicates will be shown at a time).

Related

How to wrap and stack items in QML, into rows and columns

I have a series of buttons that I want to appear in columns at the bottom of my QML page. The number of columns across should depend on the width of the window, as the window width increases I want more columns to be added. (And fewer rows as a result as components are pulled up to the previous line)
This is sort of like a Flow component, but I want the items to appear in columns, evenly spaced across the page, in rows and columns (columns centered vertically, at the bottom of the page). Sort of like GridLayout.
I can't figure out what QML component(s) to use to achieve this.
I think what you're looking for is a GridView. See the layout documentation.
I'm not positive, but based on your description I think you would just need to set the flow property to GridView.FlowTopToBottom.

Button auto width per content but in steps aligned to page grid

I would like to implement page grid-dependant width buttons so that they have quasi-auto width depending on the content, but with certain width steps so that button width always takes N number of page grid columns. When button content becomes too wide to render button in a single grid column, it would then become 2 columns wide (or even more if required)...
This image shows an example how buttons should be sized according to grid:
First row displays the second button that exceeds single column width (actually it exceeds two columns) and should therefore span 3 columns in the page grid. Second row shows the button correctly sized so it takes 3 full page grid columns.
How can this be done using only CSS (if at all)?
Note: I know this can be accomplished using Javascript, but I'm looking for a CSS-only solution if possible which may use flex, grid or whatever else layout that CSS3 provides.
You can use the CSS3 property auto-fill and auto-fit. See the Below Link
https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns

How to handle Orientation (Landscape or Portrait ) in ListView using Xamarin Forms

I am using ItemTemplate ( that is ViewCell ). I got know about the Orientation article in Xamarin documentation but there is no point about handling ListView orientation.
Hope to get the answer
Screen shots
http://i.stack.imgur.com/lkMvC.png
http://i.stack.imgur.com/5PrJj.png
As you can see from your screenshots, this is not an orientation problem, your listview IS the full width in both cases, what is quite possibly wrong are your layout options.
Can you show us your item template definition?
You are using a grid inside the ViewCell?
In that case, first make sure the grid's horizontal options are set to FillAndExpand, then check the grid column size definition.
Can you also show us the grid's column size definitions?
If they all have fixed sizes assigned, then they will always be that size, no matter how much unsued space there is.
There are 2 ways to make them use more space.
If possible, you should use the "star" sizes. This is where you give your columns sizes as portions of the available space.
If you give your first column the size 1*
and the second column size 1*
they will both take exactly half of the available width.
You can use any other numbers to select portions, such as three columns with sizes 5* 3* 1*
Which would make your first column 5 times as big as the third, and the second column would be 3 times as big as the third.
Again, in total, they will take the entire available width.
The second column sizing option is to use "Auto" sized columns, which will size the columns according to the elements inside them. Whatever size the largest element inside that column (in any of the rows) takes, that is the size that column will have.
To take the whole screen width in this case, at least one of the columns content should have "AndExpand" on it's horizontal options.
This is somewhat easier as it will automatically size the columns and you just take care of populating them properly with content, but be wary as this approach is significantly slower.
Finally, if you experience performance issues, consider implementing the ViewCell with an AbsoluteLayout. It can be a bit more pain to set up, but should work faster than grid if you have a bunch of rows inside the list view and a bunch of data in each row.

Shortening the height of a data grid to fit rows of variable height

Context for this question
We have a web page that has two scrolling grids, not paginated grids. When the first grid is nearly empty, occasional users do not realize they can scroll down to see the second grid. Other layouts (tabs, etc. are not a desirable solution).
Aside. The entire page layout is due for an overhaul, but on the Development schedule it's still 2 years away. Today, we cannot remove the grids, and we cannot change the general layout of this page.
When the first grid contains very little content, it would be good to auto-shorten the first grid so that the second grid peeks up above the fold. But when the first grid has lots of content, it's better if the first grid remains at its default height, because this grid is where the main interaction takes place, and we don't want excessive scrolling.
The challenge is that, in the grids, each row varies in height to fit its content. Sometimes a row is 2 lines of text, sometimes 12 lines of text. This causes a hard-coded height based on the number or rows inappropriate.
The question
What methods are there to assess the height of the row content in the first grid so that, if the total is less than the default grid height, we can shorten the grid? Or is there another way to look at this problem?

Dynamic CSS for 2 columns

Is there a way to create a dynamic CSS for 2 columns? What I mean is, there are 2 columns in my webpage, the left and right column. It is similar to Facebook, where the profile picture is the left column and the right column is where your feeds are located. When a link is selected from the left column, without refreshing the page, the right column will display the page automatically. The left column is where my links are located and it is fixed. The only change factor is my right column. How can I create and apply the CSS?
You don't need a CSS template in order to use columns. All you need to do is set your column widths to percentages instead of pixels. If you're using a three column grid, with one div taking one column and the other spanning two, then the percentage for the first column would be 33.3333333% (don't bother rounding up, the browser will take care of it) and the second div would be 66.6666666%.
Also, in order for your second div to refresh without loading another page, you'll have to use Ajax.
There are css3 columns but they are not supported by IE. What a surprise!
It sounds more like you just need a css layout framework. Search for css frameworks / templates.
I of course recommend simpl.css.
The page is ugly at the moment but will be updated soon.

Resources