gpt4 book ai didi

html - 当按钮在 Firefox 中处于事件状态时如何防止按钮文本移动?

转载 作者:太空狗 更新时间:2023-10-29 13:15:19 24 4
gpt4 key购买 nike

示例:

<button>Button</button>


button {
border: medium none;
margin-top: 17px;
width: 224px;
height: 40px;
background: none repeat scroll 0% 0% #7BA6BB;
color: #FFF;
outline: medium none;
cursor: pointer;
}

http://codepen.io/anon/pen/ByaLZN

浏览器:Mozilla Firefox(最新版)

单击按钮(激活)时,按钮文本向右移动。如何预防?

最佳答案

作为解决方案之一:为 button:active 添加 padding:0

button {
border: medium none;
margin-top: 17px;
width: 224px;
height: 40px;
background: none repeat scroll 0% 0% #7BA6BB;
color: #FFF;
outline: medium none;
cursor: pointer;
}

button:active {
padding: 0px;
}
<button>Button</button>

或者您可以将 span(或者您喜欢的其他标签)添加到您的 button 中,如下所示:

button {
border: medium none;
margin-top: 17px;
width: 224px;
height: 40px;
background: none repeat scroll 0% 0% #7BA6BB;
color: #FFF;
outline: medium none;
cursor: pointer;
}

button:active {
padding: 0px;
}
<button><span>Button</span></button>

关于html - 当按钮在 Firefox 中处于事件状态时如何防止按钮文本移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26908309/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com