简体   繁体   English

如何针对包含多个换行符的段落中的特定文本内容?

[英]How to target specific text content in a paragraph which contains multiple line breaks?

So here is the weird thing I am clueless on.. 所以这是我一无所知的奇怪事情。

Below is the sample snippet of the HTML, 以下是HTML的示例代码段,

<p>This is a paragraph with <br><br> two weird line breaks <br><br> and that too TWICE!</p>

Now the issue is, I want to apply CSS to the text This is paragraph OR the content after first-double line breaks. 现在的问题是,我想将CSS应用于文本“ This is paragraph或第一个双行换行符后的内容。

I tried br + br or nth-selectors, all css selectors I could think of, but it didn't worked out. 我尝试了br + br或nth-selectors,我能想到的所有css选择器,但是没有成功。

Tricky part is, I do not want to do by javascript, or else I would have done it easily accompanied by 'complexity'. 棘手的部分是,我不想用javascript做,否则我很容易伴随“复杂性”来完成它。

Any hints or solution to this problem by CSS ONLY!! CSS对此问题的任何提示或解决方案!!

Thanks! 谢谢!

You could do this by adding in HTML. 您可以通过添加HTML来做到这一点。 I dont think there is a CSS specific way to do this. 我不认为有CSS的特定方式来执行此操作。

<p><span id="snippet">This is a paragraph with </span><br><br> two weird line breaks <br><br> and that too TWICE!</p>

Then apply your CSS like this 然后像这样应用你的CSS

#snippet{
//css styles go here
}

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

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