输入的值[类型= "button" ] 通过 CSS 更改为可复制的文本?



我想将输入[type =" button"]更改为文本,因为我想在输入按钮的值中复制文本,意味着如果我拖动按钮的文本我可以轻松复制该文本。

这是我的代码:

<input type="button" value="TELL ME MORE">

是否可以使按钮的值轻松复制?

我不希望从其他文件中申请内联CSS。

您只需要添加此CSS

input[type="button"]{
user-select:text;}
<input type="button" value="Tell us more">

使用CSS类,这样您可以控制要选择的按钮。

/*use this to element where selection is allowed*/
.selectable{
user-select:text;}
/*use this to element where selection is not allowed*/
.notselectable{
user-select:none;}
<html><body>
<input class = 'selectable' type="button" value='Select Me'>
<div class = 'notselectable'> Unselectable text</div>
<input class = 'notselectable' type="text" value='Css will have no effect on me I am selectable by default'>
<input class = 'notselectable' type="text" disabled = 'true' value='Even if you disable me, text can be selected '>
</body></html>

最新更新