Css flexbox conditional wrapping - css

I have a skinny list that I'm showing in a resizable panel. The items in the list itself are dynamic (not known before hand and generated using "ng-for" directive in angular).
The panel I'm showing the items in can be resized to pre-set which is a factor of some min-width. So let's say the min-width is 100px, the user can resize the panel to be 200, 300 or 400px.
The way I need to style it is a bit complex and I'm wondering if it's even possible.
If the panel is min width (100px) show the items in a single column with vertical scroll if list overflows max height (300px). (in the example below, you've to scroll to see the 3rd item)
|item1|
|item2|
|item3|
If the user resizes the panel and increases the width, on overflow, the items should start wrapping.
|item1| |item3|
|item2|
I was playing around with flex box and wondering if I can conditionally set the flex-wrap property.

Related

jqGrid - Keep vertical scroll bar visible with both horizontal and vertical scrollbars

The situation is a jqGrid inside a div where the size of the grid is larger than the div both vertically and horizontally. The goal is to have the column headers scroll left and right with horizontal scroll, and also keep them always visible when scrolling vertically.
It is easy enough to add CSS to have both scrollbars by setting overflow-x: auto to the div containing the jqGrid and overflow-y to auto for the ui-jqgrid-bdiv.
The problem with this technique is that the vertical scrollbar is only visible when the grid is scrolled horizontally to the right enough to show the right side of the grid. Making the ui-jqgrid-bdiv scroll and using DOM manipulation to set the sizes of the containing elements results in both scrollbars being visible, but the body content scrolls without scrolling the column headers.
There is a similar stack overflow question JqGrid add vertical scroll with horizontal scolling, but the answers do not address this.
It doesn't look as if there would be a pure CSS solution given the DOM structure of the grid. Is there a JavaScript solution out there, perhaps one listening to scroll events?
You could set the height and width property of the grid itself so that the grid will take care of the scrolling instead of the div that it is nested in. Set the dimensions to be the same or slightly smaller than the div's.
<div style="height:200px; width:100px;">
<table id="grid"></table>
</div>
<script>
$("#grid").jqGrid({
height: '200',
width: '100',
shrinkToFit: false //Tells the grid to let columns go to set size
//Add all your properties
});
</script>
OR
if you can get away with not setting the width and height of the parent div, you can just set the grid's dimensions like shown above. As long as the grid's properties are set to a certain size, it will make it's own scroll bars if the data is outside of those bounds.
jsFiddle

gwt ScrollPanel in TabPanel: no vertical scrollbar

EDIT
I have fixed the whitespace behaviour by resizing components within the VerticalPanel, that seem to have had an effect on the panel's dimension somehow missed by the console. I don't quite understand how.
However, I am still stuck with none of my panels showing vertical scroll bars.
In a GWT project, I have the following structure:
Page
DockLayoutPanel
North (header)
Center (body)
South (footer)
/DockLayoutPanel
Body
SplitLayoutPanel$1
West
SplitLayoutPanel$2
North
Center
TabPanel
ScrollPanel
VerticalPanel
-Several widgets-
/VerticalPanel
/ScrollPanel
/TabPanel
/Center
/SplitLayoutPanel$2
/West
Center
/SplitLayoutPanel$1
My problems are with the ScrollPanel in the TabPanel, which in itself contains a VerticalPanel containing several widgets. This is true for each Tab in the TabPanel.
My problem is that, while the width's for all containers in SplitLayoutPanel$2's center have 100% width, the ScrollPanel contains a horizontal scrollbar with a considerable white area next to it's VerticalPanel, while they are in absolute metrics the same size.
Illustrating the situation
This is the TabPanel, with ScrollPanel, and VerticalPanel. Notice how the horizontal scrollbar exists, while the TabPanel, ScrollPanel and VerticalPanel have the same width. Scrolling to the right yields a white area.
The ScrollPanel and VerticalPanel all sport an absolute width of 598px. The West component of the DockLayoutPanel has a size of 600, so that matches. Also notice how bringing up the developer console has made the scrollbar disappear. In fact, the entire panel has disappeared behind it, and no vertical scrollbar pops up.
When scrolling the bar to the right, the VerticalPanel gets partially placed off screen, and the ScrollPanel shows this whitespace. Obviously, I don't want the whitespace to be there, so there won't be need for a scrollbar at all. All panels in this situation still have the same width: 598px. Resizing the SplitLayoutPanel, using the border to the right, increases these values (obviously), but the panels do still share equal width and the whitespace remains the same size, while I'd expect it to get wider too.
The second tab contains a load of text, which continues off the screen, but no scrollbars appear.
Problem conclusion
No vertical scrollbars
A horizontal scrollbar with some magically summoned whitespace
Compontents claim to have equal width
Any help is greatly appreciated.
EDIT
Have tried resizing the VerticalPanel to 90 or 80% width. The whitespace seems unaffected and it shows that 100% really covers the visible width and not more.
TabPanel (at least the one from GWT proper) resizes from the inside-out: its size varies depending on the size of the selected tab. So your ScrollPanel will never have a vertical scrollbar unless you explicitly give it a size, and your content is actually overflowing the layer of the SplitLayoutPanel you put the TabPanel in.
Layout panels, such as TabLayoutPanel, on the other hand resize from the outside-in: the SplitLayoutPanel would set the size of the TabLayoutPanel in its center region, and the TabLayoutPanel would in turn set the size of the ScrollPanel, so if the content of the ScrollPanel overflows, a vertical scrollbar appears.
First Point : Don't mix and match layout panels and non - layout panels.
Second Point : If you want proper resizing and scrollbars, always try to mention width and height in percentages.
I see that you have mentioned width to be 100%. But what about the height?
What I suggest for you is,
Change TabPanel to TabLayoutPanel
Set all the panels height throughout the heirarchy as 100%

Flex 4 List - scrollbars become visible and cover the itemrenderer

I have a list inside a VDividedBox. When the box is resized so the vertical scrollbar shows on the list, it covers some of the itemrenderers. How do I get the list to resize horizontally so that the scrollbar does not cover the renderers?
Actually, I'm fairly sure it's not the list scrollbar that's showing, but the VDividedBox's, hence why it's covering the list. It's a known bug in Flex 3. If I were you, I'd set the height of the list at 100% and remove the scrollbar by doing horizontalScollPolicy="off" on the VDividedBox.

How to create a Scroll in GridView using ASP.NET

How do I create a scroll in GridView using ASP.NET without using fixed sized div's around it like shown here http://www.aspnettutorials.com/tutorials/controls/gridviewscroll-aspnet2-csharp.aspx .
You can set the div's width or height to a percentage as well, and with overflow:auto, the div contents will scroll if the browser is sized to less than the content.
Without any size settings, your div will simply expand to hold all content, so a percentage, fixed, or inherited size in at least one dimension is required for scrolling to ever occur.
In order to get a scroll bar, you need a fixed height container with overflow set to scroll.
Whether you do it with the grid's properties, like in the example you linked, or by just wrapping it in a Panel with a height and overflow set on it, it doesn't matter much. The key thing is just to get it inside a fixed height container. How you want the UI to look (where the scrollbar is, etc.) will dictate where you create the div.

Resize header and footer width on window resize

I've coded myself into a corner or I am overseeing something obvious here. I have a semi-fluid CSS layout that is designed like this:
header - 100% width at all times, contains a x-repeated background image
container - fluid (960px to 1200px, centered, contains two columns)
footer - 100% width at all times, contains a x-repeated background image
In almost all cases this works fine.
In summary, the design as a whole scales to any width, yet the content part only to 1200px at a maximum. However, since this concerns a photo site, sometimes images are wider than the container width of 1200px and the image breaks out of it. This is perfectly fine, I want the full image to be shown. However, I want the header and footer to scale to the widest element, in this case the image. This is not happening and is particularly troublesome when I resize the window to a width less than the image and then scroll to the right using the horizontal scrollbar: it leaves a clear gap on both the header and footer whilst I want them to stretch to at least the image/content width.
Simply setting the width to 100% is not enough as that concerns the viewport, not the content width. I can forcefully use min-width with a large value for the header and footer, but that leaves a horizontal scrollbar in normal resolutions. I could hide that scrollbar using overflow:hidden but that would chop of content and not display a scrollbar when the window is small.
To make a long story short, I guess what I want is that this layout would work as a table would work: if one column's content is wider than its size, it pushes all other rows to that same width. The largest width determines the total width. I prefer a solution without javascript, but am thinking it is either not possible or I am overseeing something very obvious?
100% width sets the element's width to 100% of the width of the element it is contained in. In your case, it seems this is the window itself (or the body element). To make the header and footer divs (I'm assuming you're using divs here) scale with the image, they will probably need to either be included in the same div that the image is in, or inside a div that the image div is also in, assuming that div is scaling to the correct width (don't assume it is scaling to fit the image).
However, in many cases using a table for your layout can be much cleaner, and will handle the type of horizontal scaling you're looking for without needing to resort to css hacks.
To make a long story short, I guess
what I want is that this layout would
work as a table would work
display: table on the common container of these elements, and display: table-row or table-cell on its children. This will not work in IE6, but clever things can be done with its CSS expression() hack to simulate this.
I would rather suggest, however, that you not set a maximum width at all, and allow the design to flow better according to the user's desired window size.

Resources