我试着使用stackoverflow上找到的解决方案来做这件事,但似乎在较新版本的firefox中不起作用。我想让红色背景占据整个按钮,但这只在chrome中有效,在firefox中不行。我添加了 button::-moz-focus-inner
css规则,应该可以解决这个问题。有谁知道如何在较新版本的firefox中做到这一点?
<style>
button {
padding: 0px;
}
label {
display: block;
padding: 1px 6px;
background-color: red;
}
button::-moz-focus-inner {
padding: 0;
border: 0;
}
</style>
<button>
<label for="myId">My Button</label>
</button>
<br />
<button>My Button</button>
<input id="myId" type="checkbox" />
你把一个标签放到了一个按钮中,并且把红色背景应用到了标签上,而不是按钮上。你最好不要使用标签标签,但如果你需要,把按钮放在标签标签里。
<style>
button {
/* Padding is pretty important for buttons */
padding: 3px 5px;
border: 0;
background-color: red;
cursor: pointer;
margin: 0px;
}
</style>
<button>My Button</button>
<!-- It is good practice to put labels right before what they are labeling -->
<label for="myId"><button>My Button</button></label>
<input id="myId" type="checkbox" />
我可能是错的,而且无论如何,我并不想无礼。但看起来你对网页开发很陌生。查找任何你有问题的css属性或标签,请上 W3Schools. 这是一个伟大的网站。 干杯,艾萨克。