我想设置一个< button>和< a>元素都采用相同的格式.我使用以下代码:
button,a { border: solid 1px black; background-color: white; color: black; font-family: 'Arial'; padding: 0 15px; font-size: 13px; height: 35px; line-height: 35px; display: inline-block; } #dummy-block { background-color: black; padding: 0; margin: 0; height: 20px; }
<div id="dummy-block"></div> <button>My Button</button> <a>My Link</a>
但是< button>元素似乎忽略了高度和我的< a>元素不会触及黑色虚拟< div>的边缘以上:
您可以在我的小提琴中测试代码:http://jsfiddle.net/gyrrcrqc/1/
解决方法
试试这个:-
button,a { background-color: white; border: medium none; Box-shadow: 0 0 1px #000 inset; color: black; display: inline-block; font-family: "Arial"; font-size: 13px; height: 35px; line-height: 35px; padding: 0 15px; vertical-align: top; }
要么:-
button,a { background-color: white; border: medium none; vertical-align:top; color: black; display: inline-block; font-family: "Arial"; font-size: 13px; height: 35px; line-height: 35px; padding: 0 15px; border:1px solid #000; Box-sizing:border-Box }