将CSS应用于用括号括起来的段落中的单词(括号) [英] Apply CSS to the words in a paragraph written in brackets (parenthesis)

查看:215
本文介绍了将CSS应用于用括号括起来的段落中的单词(括号)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的情况。 < span> 元素中的单词来自资源键。括号中的内容需要有稍微不同的CSS。例如 -

Guys here's the situation. The words in the <span> element are coming from a resource key. And the ones inside the parenthesis need to have slightly different CSS. For example -

<span>Hello this a wonderful resource. (I mean it)</span>

现在的要求是,我的意思是它应该比其余的字更小的字体。原因是,我的意思是是一个事后的想法和文本溢出奇怪,由于大字体,他们不想为它分配另一个资源键。任何想法如何实现呢?

Now the requirement is, "I mean it" should have smaller font than rest of the words. The reason is, "I mean it" is an afterthought and the text overflows weirdly due to large font and they don't want to allocate another resource key for it. Any idea how to achieve that?

推荐答案

这可能不适合你,因为我不知道你对文本和字词的一致性有多少控制,一种方法实际上可以用之后设置内容:

This might not work for you as im not sure how much control you have over the text and the consistency of the words but one way could be actually setting the content with :after

绝对不是最佳做法

方法1:通过以下方式设置内容:after(假设您可以在数据库中编辑文本)

Method 1: Set content via :after (assuming you can edit text in the database)

span:after{
  content:" (I mean it)";
  font-size:.7em
}

<span>Hello this a wonderful resource.</span>

方法2:对方法1执行Simalar,但这是假设您没有修改文字的密码(漂亮草率)

span{
  position:relative
}
span:after{
  content:" (I mean it)";
  font-size:.7em;
  background:#FFF;
  position:absolute;
  right:0;
  padding:5px;
  width:7em
}

<span>Hello this a wonderful resource. (I mean it)</span>

这篇关于将CSS应用于用括号括起来的段落中的单词(括号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆