本文介绍了禁用空间的可选性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下HTML代码:
.meta {user-选择无; } .meta + .bash :: first-letter {user-select:none; background-color:#ff0000;}
< span class =meta> $< / span>< span class =bash> ls< / span>
现在我想要用户能够选择 ls
,但不是 $
(包括空格)。
虽然这适用于 $
字符,但它不适用于之后的空格。为什么不?我的选择器有什么问题?
PS:我对HTML代码没有任何影响,我的 only 选项是对CSS进行更改。
解决方案
试试这个,在@ ajreal的评论中创建。 div class =snippetdata-lang =jsdata-hide =falsedata-console =truedata-babel =false>
.meta {user-select:none;}。bash {display:inline-block;}。meta:after {content:'\00a0 ';}
< span class =meta> ; $< / span>< span class =bash> ls< / span>
I have the following HTML code:
.meta {
user-select: none;
}
.meta + .bash::first-letter {
user-select: none;
background-color: #ff0000;
}
<span class="meta">$</span>
<span class="bash"> ls</span>
Now I want the user to be able to select the ls
, but not the $
(including the space).
While this works for the $
character, it does not work for the space after it. Why not? what's wrong with my selector?
PS: I have no influence on the HTML code, my only option is to make changes to the CSS.
解决方案
Try this, created on @ajreal's comment.
.meta {
user-select: none;
}
.bash{
display: inline-block;
}
.meta:after {
content: '\00a0';
}
<span class="meta">$</span><span class="bash"> ls</span>
这篇关于禁用空间的可选性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!