gpt4 book ai didi

html - anchor ,按钮不是通过相等的填充水平

转载 作者:太空宇宙 更新时间:2023-11-04 11:37:49 25 4
gpt4 key购买 nike

这个问题我想了很久。每当我通过标签或按钮标签在 html 中创建一个按钮并给 css 样式填充顶部,底部等于按钮。但是按钮仍然水平对齐。供引用查找图像。

enter image description here

如需更多引用,请查找 JS FIDDLE

代码如下:

a{
display:inline-block;
text-transform:uppercase;
background:#1a8acf;
padding:10px 20px;
text-decoration:none;
color:#fff;
font-family: arial, tahoma, helvetica, sans-sarif;
}
button{
border:none;
padding:10px 20px;
background:#14214d;
color:#fff;
font-family: arial, tahoma, helvetica, sans-sarif;
}

最佳答案

line-height 在这里很重要,较小的字体具有较小的默认 line-height。为两个元素设置相同的高度并调整小的直到它们相等。 line-height 也使字体居中。

// set line height
.line-height{
line-height: 20px;
}

// remove some button default styles (Firefox)
button::-moz-focus-inner{
padding : 0;
border : 0;
}

// using block elements and floating
a{
float: left;
display:block;

text-transform:uppercase;
background:#1a8acf;
padding:10px 20px;
text-decoration:none;
color:#fff;
font-family: arial, tahoma, helvetica, sans-sarif;
}

button{
display: block;
float: left;

border:none;
padding:10px 20px;
background:#14214d;
color:#fff;
font-family: arial, tahoma, helvetica, sans-sarif;
}

JSFiddle

关于html - anchor ,按钮不是通过相等的填充水平,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31605435/

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