Flexbox + overflow:hiddden works only in Chrome - html

I am having problem with contents of my left sidebar not respecting overflow:hidden anywhere other than Chrome browser.
In Firefox, IE and Edge sidebar is extended instead of being limited to 300 pixels of .container div. Does anyone know how to fix this behavior?
https://jsfiddle.net/o1uu1d0L/2/

Try to change
.flex-fill {
display:flex;
flex:1 1 auto;
}
to
.flex-fill {
display:flex;
min-height: 0;
flex:1 1 0%;
}
I think there are two reasons why this problem occurs:
The first problem is that IE does not accept unitless flex-basis. That's why you have to use flex: 1 1 0% or flex: 1 1 0px but not flex: 1 1 0. And flex: 1 1 auto did not work in this case as well.
The second problem is different interpretation of display: flex in Chrome and Firefox. Firefox, by default, sets min-height: auto; min-width: auto; on display: flex elements and Chrome sets it as min-height: 0; min-width: 0. And what you need is second option.
I'm not sure if that simple change will solve all your problems (but it looked ok when i tested it on IE and Firefox). If not, please think about what I wrote and make similar changes in other classes. I hope it will help!

your codes with a few changes :
<div class="container">
<div class="flex-col flex-fill">
<div class="flex-row flex-fill">
<div class="flex-col flex-50 dragscroll default-box" style="margin-right:5px;">
<div class="button selected">1</div>
<div class="button">2</div>
<div class="button selected">3</div>
<div class="button">4</div>
<div class="button">5</div>
<div class="button selected">6</div>
<div class="button selected">7</div>
<div class="button">8</div>
<div class="button">9</div>
<div class="button">10</div>
</div>
<div class="flex-fill default-box">
center
</div>
<div class="flex-250 default-box" style="margin-left:5px;">
side
</div>
</div>
<div class="default-box flex-50" style="margin-top:5px;">
bottom
</div>
</div>
</div>
.container {
width:500px;
height:300px;
display:flex;
flex-flow:column;
background:lightblue;
}
.buttons-container {
min-height:1px;
height:100%;
flex:0 1 50px;
border:1px solid #CCC;
background:#FFF;
margin-right:5px;
overflow:hidden;
display:flex;
flex-flow:column;
}
.flex-col {
display:flex;
flex-flow:column;
overflow:hidden;
}
.flex-row {
display:flex;
flex-flow:row;
overflow:hidden;
}
.flex-fill {
display:flex;
flex:1 1 auto;
}
.flex-50 {
display:flex;
flex:0 0 50px;
}
.flex-250 {
display:flex;
flex:0 0 250px;
}
.default-box {
background:#FFF;
border:1px solid #CCC;
}
.plot-area {
display:block;
position:relative;
flex:1 1 auto;
background:#FFF;
border:1px solid #CCC;
box-shadow:1px 1px 4px rgba(0,0,0,0.1);
}
.button {
background:#cfeceb;
vertical-align:middle;
margin-bottom:5px;
text-align:center;
color:#56b6b2;
cursor:pointer;
font-size:26px;
flex:1 1 auto;
display:flex;
flex-direction:column;
justify-content:center;
min-height:50px;
}
.button.selected {
background:#56b6b2;
color:#FFF;
}
.button:last-child {
margin:0 !important;
}

Related

align-items : what is the difference between flex-start and Stretch?

can you please tell me align-items : what is the difference between flex-start and Stretch?
.container {
height: 500px;
padding: 10px;
margin: 50px auto;
background: #eee;
display: flex;
align-items: flex-end
}
.container .box {
padding: 10px;
width: 200px;
height: 200px;
background-color: #fff;
}
<div class="container">
<div class="box"></div>
</div>
You will see no difference if you set a height to your element.
stretch
Flex items are stretched such that the cross-size of the item's margin box is the same as the line while respecting width and height constraints.ref
In your case, nothing will happen with stretch because of the height you set.
flex-start
The cross-start margin edges of the flex items are flushed with the cross-start edge of the line. ref
This is simply align the item on the top. Again, nothing will happen visually since it's somehow the default behavior (not the default value).
.container {
display:inline-flex;
width:200px;
height:200px;
border:2px solid;
}
.container > span {
width:100px;
height:100px;
background:red;
}
<div class="container" style="align-items:flex-start">
<span></span>
</div>
<div class="container" style="align-items:stretch">
<span></span>
</div>
Now remove the height constraint and you will see the difference:
.container {
display:inline-flex;
width:200px;
height:200px;
border:2px solid;
vertical-align:top;
}
.container > span {
width:100px;
min-height:100px;
background:red;
}
<div class="container" style="align-items:flex-start">
<span></span>
</div>
<div class="container" style="align-items:stretch">
<span></span>
</div>

display flex - keeping last element in full width

I am trying to keep my 3d element with full width of the flex container. but not getting the reuslt. any one suggest me the right way for ie11 here?
.parent{
border:1px solid red;
display:flex;
justify-content:space-between;
padding:0 40px;
}
.child{
flex:0 0 30%;
border:1px dashed green;
}
.child.last{
/* not working */
width:100%;
}
<div class="parent">
<div class="child">one</div>
<div class="child">two</div>
<div class="child last">three</div>
</div>
To enable for the last child to wrap and be 100% wide, add flex-wrap: wrap to parent and use flex-basis on last child.
.parent{
border:1px solid red;
display:flex;
flex-wrap: wrap;
justify-content:space-between;
padding:0 40px;
}
.child{
flex:0 0 30%;
border:1px dashed green;
}
.child.last{
flex-basis: 100%;
}
<div class="parent">
<div class="child">one</div>
<div class="child">two</div>
<div class="child last">three</div>
</div>
To make the last child 100%-width only after wrapping...
Use flex: 1:
The flex property specifies the length of the item, relative to the rest of the flexible items inside the same container. It makes the flex item flexible and sets the flex basis to zero, resulting in an item that receives the specified proportion of the remaining space.
.parent{
border:1px solid red;
display:flex;
justify-content:space-between;
padding:0 40px;
}
.child{
flex:0 0 30%;
border:1px dashed green;
}
.child.last{
width:100%;
/* SOLUTION */
flex: 1;
}
<div class="parent">
<div class="child">one</div>
<div class="child">two</div>
<div class="child last">three</div>
</div>

Need assistance with specific CSS div layout

I've been fiddling with this for a while and can't get what I want. Can someone give me some guidance to achieve the layout in the attached drawing?
I started this off for you. It uses flexbox which is a suggestion by #Keith M (and a good one, I would also recommend flexbox).
Hope it gets you on your way!
.body {
display:flex;
flex-direction:column;
width:100vw;
height:100vh;
}
.body > .topNav {
flex:0 0 50px;
background: blue;
}
.body > .page {
display:flex;
flex-direction:row;
flex: 1 1 auto;
}
.body > .page > .leftNav{
flex: 0 0 300px;
background: red;
}
.body > .page > .content{
flex: 1 1 auto;
}
<div class="body">
<div class="topNav">
</div>
<div class="page">
<div class="leftNav">
</div>
<div class="content">
</div>
</div>
</div>

align content-div element inside of wrapper-div

I have struggled to align content-div elements of a wrapper-div using only CSS with the following restriction.
The wrapper div can have a row which allows multiple content-div elements be on the row
At most 4 content-div elements can exist on a row of the wrapper div.
Content-div elements of the last row must expand to fill the row. (e.g if 3 content-div elements exist on the last row, then the width of each content-div should be 33.3%)
One and only one content-element always is selected, and the selected element should be bottom-left conner of the wrapper-div element.
To handle this, I have tried the following css.
.wrapper{
width:100%;
}
.content{
max-width:100%;
min-width:25%;
background-color:white;
float:right;
}
.content.selected{
position:absolute;
top:100%;
left:0;
float:left;
background-color:yellow;
}
I thought that the "float:right; float:left position:absolute; top:100%; left:0;" option can handle the restriction 1 and restriction 4, the "min-width:25%" option can handle the restriction 2 and the "max-width:100%" option can handle the restriction 3. However, only a few restriction were satisfied through the CSS.
I have setup jsFiddle example:
https://jsfiddle.net/6qyc5kLw/2/
I would help in this regard.
This image is what I want to do.
ever considered display:flex? its HUGE!
.wrapper{
width:100%;
position:relative;
display: flex;
flex-flow:row wrap;
align-items: stretch;
}
.content{
min-width:25%;
background-color:white;
//float:right;
flex:1;
order:1;
}
.content.selected{
//position:absolute;
//top:100%;
//left:0;
//float:left;
background-color:yellow;
order:-1;
}
The new flexbox possibilities are most certainly what you are looking for. See below snippet or https://jsfiddle.net/6qyc5kLw/3/ for an updated demo with some basic flexbox properties. An additional one would be
flex-order (to reverse the order of elements in first row)
.wrapper{
width:100%;
position:relative;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.content{
flex-basis: 25%;
background-color:white;
border: 1px solid #ccc;
flex-grow: 1;
box-sizing: border-box;
}
.content.selected{
align-self: flex-end;
background-color:yellow;
}
<body>
<div class="wrapper">
<div class="content">
1
</div>
<div class="content">
2
</div>
<div class="content">
3
</div>
<div class="content">
4
</div>
<div class="content selected">
5
</div>
<div class="content">
6
</div>
<div class="content">
7
</div>
</div>
</body>
You can use display: flex
.wrapper{
width:100%;
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
.content{
background:#fff;
box-flex: 1;
min-width:25%;
flex: 1;
margin: auto;
}
.content.selected{
background-color:yellow;
}
<div class="wrapper">
<div class="content">1</div>
<div class="content">2</div>
<div class="content">3</div>
<div class="content">4</div>
<div class="content selected">5</div>
<div class="content">6</div>
<div class="content">7</div>
</div>
Here is exactly what you want in example picture:
.wrapper{
width:100%;
position:relative;
}
.content{
max-width:100%;
min-width:25%;
background-color:white;
float:right;
border: 1px solid black;
box-sizing: border-box;
}
.content.selected{
background-color:yellow;
float: left;
width: 33.33%;
}
.content:nth-child(6) {
float: right;
width: 33.33%;
}
.content:nth-child(7) {
float: left;
width: 33.33%;
}
<body>
<div class="wrapper">
<div class="content">
1
</div>
<div class="content">
2
</div>
<div class="content">
3
</div>
<div class="content">
4
</div>
<div class="content selected">
5
</div>
<div class="content">
6
</div>
<div class="content">
7
</div>
</div>
</body>

CSS Fixed Fluid Columns with no extra markup?

I'm looking for a way to create a CSS layout where the left column is fluid and the right column is fixed using the exact markup below. I don't think it is possible. Am I wrong?
<div class="wrapper">
<div class="left">Fluid Column</div>
<div class="right">Fixed Column</div>
</div>
Yep. Try this:
<div id="wrapper">
<div id="left">
<div id="content">
...
</div>
</div>
<div id="right">
...
</div>
</div>
CSS:
#wrapper { width: 900px; }
#left { float: left; width: 100%; margin: 0 -100px 0 0 ; }
#content { margin: 0 100px 0 0; }
#right { float: right; width: 100px; }
Note: Remove wrapper if you want the width to be 100%.
It's probably not a viable solution at this point in time but if you are not adverse to using bleeding-edge CSS you could also use the CSS3 flex box module. Using vendor specific prefixes, it is currently supported in Firefox, and Webkit based browsers such as Safari and Google Chrome.
<!doctype html>
<style>
.wrapper {
display: -moz-box;
display: -webkit-box;
display: flexbox;
-moz-box-orient: horizontal;
-webkit-box-orient: horizontal;
flex-direction: lr; /* box-orient has been renamed in the most recent version of the draft */
width: 100%;
}
.right {
width:150px;
background-color: #eee;
}
.left {
-moz-box-flex: 1;
-webkit-box-flex: 1;
flex-box: 1; /* box-flex has been renamed flex-box */
}
</style>
<div class="wrapper">
<div class="left">Fluid Column</div>
<div class="right">Fixed Column</div>
</div>
For the sake of semantics, you might want to rename .left and .right to something like .content and .sidebar
Give this a shot:
* { padding:0px; margin:0px; }
.wrapper {
position:absolute;
width:100%;
height:100%;
}
.left {
position:absolute;
top:0; bottom:0;
left:0; right:150px;
background-color:#999999;
}
.right {
position:absolute;
top:0; bottom:0;
right:0;
width:150px;
background-color:#AAAAAA;
}