问题描述
我正在尝试创建一个仅用下划线标出第一个字母的按钮.显然我不能使用标签,然后使用伪元素:first-letter在CSS中实现它.它在其他情况下效果很好,但是在按钮中不起作用.还有其他解决方案吗?
I'm trying to create a button with only the first letter underlined.Obviously I can not use tags , then I would realize it with css, by using the pseudo element :first-letter. It works very well in other contexts, but in button doesn't work.There are other solutions?
推荐答案
由于您尚未共享代码,因此我将在此处进行大胆的猜测.
Since you haven't shared your code, I'll take a bold guess here.
您使用的是< input type ="button" value ="Some Value">
,因为里面没有实际的文本(显示的文本来自 value =
属性),:first-letter
无效(因为它适用于元素内部的文本).
You're using <input type="button" value="Some Value">
, because there's no actual text inside (The displayed text comes from the value=
attribue), :first-letter
wouldn't work (because it works on the text inside of the element).
相反,请使用< button> Some Value</button>
,它应该可以正常工作.
Instead, use <button>Some Value</button>
, it should work fine.
这篇关于在输入按钮上使用:first-letter伪元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!