Comments (6)
flex: 1 1 0%
will work to make the content boxes of an unknown set of flex items all the same size. If you need to add padding to one of the items (but not all of them), the sizing will be different. You can get around this by making a child element and putting the padding on that.
from flexbugs.
It's working as intended. I think you may be confusing the width aspect vs. the flex grow/shrink aspect.
When you say flex: 1 1 0%
you're saying the width should be 0%
, and then it should grow/shrink proportionally. You're not saying it should have a width of 50%
.
And when you give something a width of 0%
, it's not actually going to be 0px
big if it has padding/border, as you can see from this example: http://codepen.io/anon/pen/PwQBrM
from flexbugs.
When you specify a flex-basis
(as you are in your flex
shorthand), the browser looks at that and completely ignores any width/height declarations. To get the browser to use your set width, use a flex-basis
of auto
, or better yet, just use a flex-basis
of 50%
since that's what you want the width to be.
from flexbugs.
@philipwalton, auto
works only if there's no content inside the items. If there is content inside, the width is distributed based on each items content's width. The only thing I can do is to set the width explicitely to 50%
, which only works if I have two items. If I have an unknown amount of items this won't work anymore. Is there no way to get equal-width items without specifying the width?
from flexbugs.
@philipwalton, yeah that's what I did for now but I was wondering why it wouldn't calculate the same widths if there's different padding while using box-sizing: border-box
. Do you may know why this behaves the same or what the reason for this is?
from flexbugs.
Ah, that's why - thanks a lot for explaining!
from flexbugs.
Related Issues (20)
- ie nested flexbox with wrap overflow bug
- inline block content in a flex container not displaced
- #4 more accurate description HOT 1
- 'Flex-direction: column' in IE11 interacts badly with 'display: table'
- `flex: 1 1 0%` is different from flex: `1 1 0px` HOT 2
- Confusing issue template HOT 6
- IE11: align-items calculate baseline as bottom of table inside flex item
- .
- iOS Safari: align-items calculates baseline as bottom of input element HOT 4
- Minimum sizing of nested flexbox in Safari HOT 7
- webkit not honouring flex-basis percentage width with images HOT 1
- CodePen does NOT support Internet Explorer 11 (IE11) HOT 14
- Addition to Flexbug #9: IE11 <tr> Element (Table Row) does not Support Flexbox
- The codepens for 12.1a and 12.1b have the same code HOT 3
- flex button child height not accepting 100 percent HOT 1
- Need code review and want to understand my hack about height=0px HOT 1
- column flex: wrong width on automatically resized img
- Align-self:center contents overflow combined with a parent's flex-direction:column
- Cant understand this issues
- Flexbug #12 (Inline elements not treated as flex-items) affected Safari 8, fixed in 9
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 flexbugs.