Comments on: width https://css-tricks.com Tips, Tricks, and Techniques on using Cascading Style Sheets. Wed, 03 Mar 2021 17:20:29 +0000 hourly 1 https://wordpress.org/?v=6.4.3 By: Nad https://css-tricks.com/almanac/properties/w/width/#comment-1761855 Fri, 21 Aug 2020 19:54:37 +0000 http://css-tricks.com/?page_id=14134#comment-1761855 Hi, thanks for tutorials
How can i to use percent and pixel for width of 3column at left (pixel), center(%) and left(pixel) of same parrent,
Thanks
..
Like this:
..






]]>
By: Geoff Graham https://css-tricks.com/almanac/properties/w/width/#comment-1758821 Fri, 03 Jul 2020 16:37:26 +0000 http://css-tricks.com/?page_id=14134#comment-1758821 In reply to Peter.

That’s super interesting, Peter! There does seem to be a difference between those definitions and what elements they include. The post has been updated. Thanks for the heads up!

]]>
By: Peter https://css-tricks.com/almanac/properties/w/width/#comment-1758802 Fri, 03 Jul 2020 13:43:56 +0000 http://css-tricks.com/?page_id=14134#comment-1758802 In reply to Peter.

The link to the relevant CSS definition of non-/replaced-element is https://www.w3.org/TR/css-display-3/#replaced-element

Maybe this misunderstanding is caused by the HTML spec to define “replaced element” differently than CSS. This should be explicitly mentioned in the article, since an article about a CSS property naturally implies using the CSS definitions of things.

]]>
By: Peter https://css-tricks.com/almanac/properties/w/width/#comment-1758801 Fri, 03 Jul 2020 13:37:28 +0000 http://css-tricks.com/?page_id=14134#comment-1758801 “Note that width applies to all elements except non-replaced […].”. Are you sure you mean “non-replaced”? This would include all elements that are not replaced, including yours truly div, p, etc. pp. I think this is a mistake.

]]>
By: Yun https://css-tricks.com/almanac/properties/w/width/#comment-1751618 Wed, 25 Sep 2019 18:47:17 +0000 http://css-tricks.com/?page_id=14134#comment-1751618 For the last example, I can get the same effect with max-content and margin.

ul { width: max-content; margin: 1em auto; }

]]>
By: Azhar Mughal https://css-tricks.com/almanac/properties/w/width/#comment-1654393 Sat, 29 Dec 2018 08:07:01 +0000 http://css-tricks.com/?page_id=14134#comment-1654393 I have an issue that I used custom CSS when give 100% of div and then making padding its exceeding the width of div.

]]>
By: Wiist https://css-tricks.com/almanac/properties/w/width/#comment-1652868 Tue, 23 Oct 2018 09:31:27 +0000 http://css-tricks.com/?page_id=14134#comment-1652868 In reply to Raf.

I think i would use the flex property on the parent div, make it so that the width of the parent is inherit the width of the picture, and make the picture flex: 1. normally like that it should all be good.

]]>
By: Wiist https://css-tricks.com/almanac/properties/w/width/#comment-1652867 Tue, 23 Oct 2018 09:27:23 +0000 http://css-tricks.com/?page_id=14134#comment-1652867 In reply to Charles Robertson.

I don’t know if you still look for the answer but from what i experience using those two:

width : 100% define the element to be 100% of the width of the parent container that got defined dimensions.
max-width: 100 % restrict the size of the element to be lower or equal to 100% of the width of the parent container that got defined dimensions.

In other words, use width if you want your element to be strictly equal to his parent, use max-width for more flexible display and a safety that your element won’t be “out of the box”.

]]>
By: Jeevan George Antony https://css-tricks.com/almanac/properties/w/width/#comment-1652608 Wed, 10 Oct 2018 14:46:12 +0000 http://css-tricks.com/?page_id=14134#comment-1652608 is there any alternative for width:max-content that could be used for IE10+ other than fallback css setting?

]]>
By: yubo https://css-tricks.com/almanac/properties/w/width/#comment-1613915 Wed, 20 Dec 2017 15:52:21 +0000 http://css-tricks.com/?page_id=14134#comment-1613915 you safe my day thanks!

]]>
By: Charles Robertson https://css-tricks.com/almanac/properties/w/width/#comment-1610237 Wed, 12 Jul 2017 23:32:36 +0000 http://css-tricks.com/?page_id=14134#comment-1610237 Can someone explain the difference between

img{width:100%;}

and

img{max-width:100%;}

This is another one of life’s great mysteries:)

]]>
By: Christine https://css-tricks.com/almanac/properties/w/width/#comment-1608655 Thu, 18 May 2017 18:27:38 +0000 http://css-tricks.com/?page_id=14134#comment-1608655 In reply to Miguel.

Hey Miguel! Can you give a real life example of “fill-available”? This sounds like something that could be extremely useful and I have just heard of it now!!

]]>
By: Miguel https://css-tricks.com/almanac/properties/w/width/#comment-1606780 Wed, 15 Feb 2017 21:56:29 +0000 http://css-tricks.com/?page_id=14134#comment-1606780 In reply to Miguel.

width: fill-available;
width: -moz-fill-available;
width: -webkit-fill-available;

]]>
By: Miguel https://css-tricks.com/almanac/properties/w/width/#comment-1606779 Wed, 15 Feb 2017 21:52:21 +0000 http://css-tricks.com/?page_id=14134#comment-1606779 Maybe you were joking about wondering what the fill-available value does, because it’s kinda obvious, its name says it all.

In case that you were not joking, what fill-available does is to give an element as much width (or height) as possible without overflowing its parent, that taking in consideration margin and padding (i.e. differently than 100% width).

I love fill-available :)

]]>
By: Raf https://css-tricks.com/almanac/properties/w/width/#comment-1605146 Tue, 22 Nov 2016 17:36:30 +0000 http://css-tricks.com/?page_id=14134#comment-1605146

If we wanted that figure element to essentially be the size of that image, so the text wraps at the edges of the image. We could float it left or right, because float will exhibit that same kind of shrink-to-fit behavior(…)

Could anyone possibly please explain how to achieve the same effect without setting up width for parental div (figure in this particular case)? I’ve been trying to float it left, or right, but couldn’t force paragraph to shrink to fit to the image size. If I’d set up the width for 200px for div, the problem solves itself, but I don’t need any floats. So, how can I achieve the same effect without specifying width for the figure, only with floats?

]]>