简体   繁体   English

将文本跨越到 div 的边缘(无空格)

[英]Span text to the edge of the div (no white-space)

I'm looking for a solution to span the text to the edge of the div.我正在寻找一种将文本跨越到 div 边缘的解决方案。 I don't want to have any white-space in the div.我不想在 div 中有任何空格。

Here is my div这是我的 div

<div class="m-card__text-front">
     <p class="fit-text">TEST TEXT</p>
     <p class="is-bold fit-text">FOO BAR</p>
     <p class="is-bold fit-text">LOREM</p>
     <p class="fit-text">LOREM IPSUM</p>
</div>

Now this looks looks at the moment like this现在这看起来像这样

在此处输入图像描述

The red marked spots that is where I want the text to go span to.红色标记的点是我希望文本到 go 的位置。

I also need the bold text to be a different size (bigger) then the other text.我还需要粗体文本与其他文本的大小不同(更大)。

I am currently using the fitText function.我目前正在使用 fitText function。 https://github.com/davatron5000/FitText.js https://github.com/davatron5000/FitText.js

Used like this: <script> $('.fit-text').fitText(0.8); </script>像这样使用: <script> $('.fit-text').fitText(0.8); </script> <script> $('.fit-text').fitText(0.8); </script>

EDIT:编辑:

Here is how the HTML looks like with the plugin:这是 HTML 与插件的外观:

<p class="fit-text" style="font-size: 38.6055px;">TEST TEXT</p>

Font size is being added automatically.字体大小正在自动添加。

EDIT 2:编辑2:

Well i just realized that i explained my problem wrong.好吧,我刚刚意识到我错误地解释了我的问题。 How I explained it your function does exactly what I described.我如何解释你的 function 完全符合我的描述。 But i want to span the text and make the letter accordingly bigger.但我想跨越文本并使字母相应更大。 That is why I tried to use that pluggin.这就是我尝试使用该插件的原因。 Sorry Englisch is not my first language.. My bad.对不起,英语不是我的第一语言.. 我的错。

Will this work?这行得通吗?

        <div class="m-card__text-front">
           <p style="font-size:19vw; white-space: nowrap; overflow: hidden;">TEST TEXT</p>
           <p style="font-size:23vw; white-space: nowrap; overflow: hidden;">FOO BAR</p>
           <p style="font-size:28vw; white-space: nowrap; overflow: hidden;">LOREM</p>
           <p style="font-size:14.5vw; white-space: nowrap; overflow: hidden;">LOREM IPSUM</p>
        </div>

JSFiddle JSFiddle

You can adjust the vw(in style) if text is too small or big.如果文本太小或太大,您可以调整 vw(in style)。 In this code, if you adjust the page size the text will adjust its font size along with the page.在此代码中,如果您调整页面大小,则文本将与页面一起调整其字体大小。

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

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