Giter Club home page Giter Club logo

Comments (6)

philipwalton avatar philipwalton commented on July 2, 2024 2

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.

philipwalton avatar philipwalton commented on July 2, 2024 1

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.

philipwalton avatar philipwalton commented on July 2, 2024

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.

thasmo avatar thasmo commented on July 2, 2024

@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.

thasmo avatar thasmo commented on July 2, 2024

@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.

thasmo avatar thasmo commented on July 2, 2024

Ah, that's why - thanks a lot for explaining!

from flexbugs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.