开发者

How do you make a variable size div?

开发者 https://www.devze.com 2023-03-06 23:01 出处:网络
How do开发者_StackOverflow中文版 I make a div that has a variable width? So I want a div to span a certain width inside a container and if there is another element in it, the div will automatically fi

How do开发者_StackOverflow中文版 I make a div that has a variable width? So I want a div to span a certain width inside a container and if there is another element in it, the div will automatically fill a portion of the of the width.


Don't give the div a width and it will fill 100% of the horizontal space. Add margins to it (as either % or px) and it will shrink accordingly.

It sounds like you may be asking how to have something inside the div force it to grow wider with its content. I don't think that's possible without javascript.

0

精彩评论

暂无评论...
验证码 换一张
取 消