简体   繁体   English

css - 宽度适合内容

[英]css - width fit to content

I built a site with the following structure: 我构建了一个具有以下结构的站点:

body
 div pos: absolute; width: 3200px
  div pos: static; width: fit-content <- 20 - 30 pcs in a row
   div pos: relative; width: 100%
    div pos: absolute; width 30%

The first div is actually a long slider, the width is manually set to fit the contents. 第一个div实际上是一个长滑块,手动设置宽度以适合内容。 But I want the width to be set automatically. 但我希望自动设置宽度。 The fit-content option results in no width at all. fit-content选项导致根本没有宽度。 Any ideas how to fix this? 任何想法如何解决这一问题?

Thanks! 谢谢!

Work with percentages like you do with the other divs. 像处理其他div一样使用百分比。 Set it to 100% instead of 3200px 将其设置为100%而不是3200px

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM