简体   繁体   English

CSS是否可以将段落中的字母定位为无跨距?

[英]Is it possible with CSS to target letters within a paragraph without span?

I'm trying to add an effect to my letters, but I don't want to add a bunch of span tags all over the place. 我正在尝试给字母添加效果,但是我不想在各处添加一堆span标签。 Is it possible to target a specific letter within a line of text with CSS? 是否可以使用CSS在一行文本中定位特定字母?

I know there is :first-child, :first-of-type, :only-child, :last-child, :last-of-type, :only-of-type ,:nth-child, :nth-of-type ,:nth-last-child and :nth-last-of-type I believe. 我知道有:first-child, :first-of-type, :only-child, :last-child, :last-of-type, :only-of-type ,:nth-child, :nth-of-type ,:nth-last-child我相信:first-child, :first-of-type, :only-child, :last-child, :last-of-type, :only-of-type ,:nth-child, :nth-of-type ,:nth-last-child:nth-last-of-type But none of these help do what I want in any combination. 但是,这些帮助都无法以我的期望来完成。

This is what I need to target letter by letter. 这就是我要逐字针对的目标。 <p>Hello.</p>

This is what I don't want. 这就是我所不想要的。 Nor lettering.js . 也没有Lettering.js

<p>
<span class"somefancyname">H</span>

<span class"somefancyname">e</span>

<span class"somefancyname">l</span>

<span class"somefancyname">l</span>

<span class"somefancyname">o</span>

<span class"somefancyname">.</span>
</p>

Lastly - Is it really bad to use that many span tags? 最后-使用那么多的span标签真的好吗? I feel dirty if I use that many... not sure why really. 如果使用那么多,我会觉得很脏...不确定为什么。 Thanks in advanced! 提前致谢! If someone can reword this to make sense - I feel I rambled a bit - thank you! 如果有人可以改写为有意义的话-我觉得我有点胡乱-谢谢!

Note: I want to add different animations to the letters. 注意:我想在字母上添加不同的动画。 Not just (1) place on the page - so that's why I'm concerned with multiple span tags. 不仅(1)放在页面上-这就是为什么我关注多个span标签。 What animations? 什么动画? Some bouncing over here and some color changing over there and maybe some rotating over yonder. 一些在这里弹跳,一些在那改变颜色,也许一些在上方旋转。 Is my only solution to use JS or just give in to the span tags? 是我使用JS还是仅允许使用span标签的唯一解决方案?

I know jquery can do this: 我知道jQuery可以做到这一点:

$(document).ready(function(){
count = 0; limit = 10;
var refreshId = setInterval( function() {
if(count < limit) {

$( '.data tr:contains("blah")') .css( {"display":"none"} );
$( '.mainpart h2 a') .css( {"text-decoration":"underline" , "color":"#38c"} )

}
else {
clearInterval(refreshId);
}
}, 2000);
});

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

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