点击时javascript按钮收缩

时间:2016-09-29 13:37:40

标签: javascript button onclick click

单击按钮时,它们正在收缩。 - 如何防止萎缩?



function aaa() {
  document.activeElement.style.backgroundColor = '#B2DD28';
}

<button type="button" onclick="aaa()">0022</button>
<button type="button" onclick="aaa()">0023</button>
<button type="button" onclick="aaa()">0024</button>
<button type="button" onclick="aaa()">0025</button>
<button type="button" onclick="aaa()">0026</button>
<button type="button" onclick="aaa()">0027</button><br>
<button type="button" onclick="aaa()">0022</button>
<button type="button" onclick="aaa()">0023</button>
<button type="button" onclick="aaa()">0024</button>
<button type="button" onclick="aaa()">0025</button>
<button type="button" onclick="aaa()">0026</button>
<button type="button" onclick="aaa()">0027</button>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

按钮不缩小,只是边框的颜色与背景颜色不同。可能边框是浅色的,所以在白色背景上它看起来像是在缩小。

解决方案是将边框颜色设置为与背景相同的颜色,如下面的代码所示:

&#13;
&#13;
function aaa() {
  document.activeElement.style.backgroundColor = '#B2DD28';
  document.activeElement.style.borderColor = '#B2DD28';
}
&#13;
<button type="button" onclick="aaa()">0022</button>
<button type="button" onclick="aaa()">0023</button>
<button type="button" onclick="aaa()">0024</button>
<button type="button" onclick="aaa()">0025</button>
<button type="button" onclick="aaa()">0026</button>
<button type="button" onclick="aaa()">0027</button><br>
<button type="button" onclick="aaa()">0022</button>
<button type="button" onclick="aaa()">0023</button>
<button type="button" onclick="aaa()">0024</button>
<button type="button" onclick="aaa()">0025</button>
<button type="button" onclick="aaa()">0026</button>
<button type="button" onclick="aaa()">0027</button>
&#13;
&#13;
&#13;