如何在标签之间选择松散文本 [英] How to select loose text between tags

查看:119
本文介绍了如何在标签之间选择松散文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您在HTML代码中找到未嵌入任何标签的文本,例如:

 < sometag& ex1< / sometag> 

我知道很多方法使用ap标签选择文本,或使用div或id ,等等,但我的问题是:你怎么写这个代码的CSS规则?此外,我想要的规则是特定的文本,因此:



sometag {...}



解决方案



简单地说,没有。目前没有选择器只能使用CSS选择TEXT。您可以(而且应该)使用标记来获取您要查找的结果:



HTML:

 < sometag> 
< span> text here< / span>
< img src ='..'/>
一些其他的东西,我不想在我的CSS中选择
< / sometag>

CSS:

 code> sometag span {
/ * do something here * /
}


In cases you find text in HTML code that is not embeded in any tags such as:

<sometag> ex1 </sometag>

I know many ways to select the text using a p tag or using a class or an id on the div, etc. but my question is: how do you write a css rule for this code as is? Also, I want the rule to be specific for the text so:

sometag {...}

is not desirable because it is more generic.

Thanks for all in advance.

解决方案

Simply put, no. There is currently no selector to select TEXT only with CSS. You can (and should) use markup to get the result you're looking for:

HTML:

<sometag>
    <span>text here</span>
    <img src='..' />
    some other stuff i don't want to select in my CSS
</sometag>

CSS:

sometag span{
    /* do something here */
}

这篇关于如何在标签之间选择松散文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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