News for hackers. Stuff that matters.
Re:CSS Findings from the Threads App by aidos on Sunday July 16, 2023 @09:10AM (#36746606)
Weeeeeeeell a div is 100% width by default. It will always fill the width of the parent container unless you explicitly change the width.
Re:CSS Findings from the Threads App by fendy3002 on Sunday July 16, 2023 @09:30AM (#36746790)
Afaik div width property is almost useless if the parent set the display as flex, or if the div has no content.
Re:CSS Findings from the Threads App by aidos on Sunday July 16, 2023 @10:31AM (#36747429)
That’s kinda the point of flex though. The width is determined by the flex rules; width 100% doesn’t make much sense in that context.
Re:CSS Findings from the Threads App by truckerbill on Sunday July 16, 2023 @09:49AM (#36746971)
Not if the parent or ancestors don't have a width set... Hence why you need context.
Re:CSS Findings from the Threads App by aidos on Sunday July 16, 2023 @11:37AM (#36748202)
The parent has _some_ width, even if it’s not explicitly set.
Re:CSS Findings from the Threads App by truckerbill on Monday July 17, 2023 @11:22AM (#36759346)
Yes, and I wish 100% would respect that implicit width but it doesn't. Try it
Re:CSS Findings from the Threads App by aidos on Monday July 17, 2023 @05:00PM (#36764010)
Any chance you could show an example? In theory a block level element can only sit inside another block level element. And those expand to the width of their parent unless you constrain the width.
Re:CSS Findings from the Threads App by truckerbill on Tuesday July 18, 2023 @07:36AM (#36770707)
https://jsfiddle.net/jcaysopd/75/

I have no doubt there is a 'logical reason' for the behaviour but it doesn't stop it being annoying to work with.

Re:CSS Findings from the Threads App by aidos on Friday July 21, 2023 @05:47PM (#36820336)
Gotcha. That’s because of the 100% vs auto thing. These days everyone just puts “box-sizing: border-box” on everything to make it go away.

This explains a bit more about what you’re seeing

http://stackoverflow.com/questions/28353625/why-does-percent...

Re:CSS Findings from the Threads App by have_faith on Sunday July 16, 2023 @10:29AM (#36747403)
100% isn’t the default value, ‘auto’ is. Which has the effect of appearing 100% in many scenarios? But not all.
Re:CSS Findings from the Threads App by aidos on Sunday July 16, 2023 @11:36AM (#36748185)
Fair, but actually that just means that the border and margin etc are pushed outside the container. In either case the div is operating by taking up the full width of the container.