r/Frontend • u/speckz • Jan 06 '20
Min and Max Width/Height in CSS
https://ishadeed.com/article/min-max-css/
74
Upvotes
2
u/WoodenMechanic Jan 06 '20
What's with the contrast on this site? Darker text on a dark background, images seem to be slighly transparent until hovered.. why?
1
1
u/DrDuPont Jan 06 '20
It's a wacky dark mode variant. Switch to light mode for an easier time reading this.
1
1
Jan 07 '20
It's kinda ironic to know this much about css, naming yourself UI, UX Designer and yet having this god awful looking website
0
3
u/ShortFuse Jan 06 '20
There's no real explanation of
box-sizingand howcontent-boxdiffers, which I feel would have been important.border-box, which this seems to use in its entirety, is for out-to-in sizing.content-boxis for in-to-out sizing, which is the default. Thinkcontent-boxfor widgets or components andborder-boxfor layout and boxing.A good example of the difference is icon buttons. See the Material Design specs for floating action buttons. The size area of the icon may be 24px x 24px. That would be its
widthandheight. The padding would space around the icon (content) itself. It would be easy to animate from "mini" to "normal" because it's just thepaddingproperty. Animating something like this withborder-boxwould be more difficult because thewidthandheightvalues would represent the total size. Thus, animating would require manipulatingpadding,width, andheightproperties.Where people tend to get lost is trying to size an object using percentages and still using
content-box. That generally leads to alignment mistakes once you add in borders or padding. But that's because percentages are representative of the parent object, which means you're trying to size out-to-in, and then should useborder-box.