我从未想过这是可能的,但这里有很多聪明的人,所以我想问一下。我正在寻找一种方法来拥有一个完整高度的容器,其宽度取决于内容量。我希望文本填充区域占用全部高度,同时使用尽可能小的宽度。高度已知且硬编码,内容量不确定。
我正在使用类似于这样的东西:
通常情况下,内容会从页面顶部填充到底部: 我需要的是相反的效果,从左到右填充:
我正在使用类似于这样的东西:
<div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled....</p>
</div>
div {
background:red url(http://lorempixel.com/600/400/);
float:left;
width:600px;
height:400px;
}
p {
background:#fff;
padding:20px;
margin:20px;
}
通常情况下,内容会从页面顶部填充到底部: 我需要的是相反的效果,从左到右填充:
内容更少时,应该看起来像这样:
使用完全硬编码的高度和width:auto
会产生这种效果:
有没有办法让文本填充最小可能的宽度,同时填满高度,而不需要硬编码宽度或出现文本溢出?这似乎是不可能的,我不知道该如何解决。欢迎使用Javascript/jQuery解决方案。