简体   繁体   English

字体大小取决于容器的宽度

[英]Font size based on container width

I'd like to create a block of text that has three lines of text, all different lengths but the same width like shown in this image (apologies for the size). 我想创建一个文本行,其中包含三行文本,所有行长都不同,但宽度相同,如该图所示(抱歉,该大小)。 I'd like to know if there is a way of doing so without creating three different elements and changing the font-size for each. 我想知道是否有一种方法可以创建三个不同的元素并为每个元素更改字体大小。 Would it be possible to set the font-size to the width of its container? 可以将font-size设置为其容器的宽度吗?

例

<div class="block pink">
<div class="block-container">
    <p>Create your</p>
    <p>30x20</p>
    <p>Canvas</p>
</div>
</div>

no. 没有。 Not with CSS. 不适用于CSS。 But there are lots of jquery plugins that will do this for you. 但是有很多jquery插件可以为您做到这一点。 Fx. FX。 http://simplefocus.com/flowtype/ http://simplefocus.com/flowtype/

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

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