css - 如何修复按钮中的不均匀填充
问题描述
这是一个疯狂的基本问题,但对于我的生活,我无法弄清楚。我正在创建一个按钮类,无论我做什么,文本的底部和右侧都有额外的空间。
尝试更改line-height
, border-box
, margin
s,display
和text-align
其他一些。
.button {
font-family: 'helvetica';
font-size: 16px;
color: #000;
margin: 0px;
position: relative;
letter-spacing: .4em;
text-transform: uppercase;
text-decoration: none;
color: $secondary-color;
border: 4px solid #000;
padding: .3em .75em;
margin: 0px;
text-align: center;
display: inline-block;
transition: all .25s ease-in-out;
-moz-transition: all .25s ease-in-out;
-webkit-transition: all .25s ease-in-out;
}
.button:hover {
color: #fff;
background-color: #000;
}
<a href="ProjectPage.html" class="button">project</a>
只是试图获得一个均匀填充的按钮,该按钮将调整为文本内容。
解决方案
发生这种情况是因为letter-spacing:0.4em
在您的最后一封信中删除此换行的最后一封信span
,letter-spacing:0
如下所示:
.button {
font-family: 'helvetica';
font-size: 16px;
color: #000;
margin: 0px;
display:inline-block;
align-items:center;
position: relative;
letter-spacing: .4em;
text-transform: uppercase;
text-decoration: none;
border: 4px solid #000;
padding: .3em .75em;
margin: 0px;
text-align: center;
transition: all .25s ease-in-out;
-moz-transition: all .25s ease-in-out;
-webkit-transition: all .25s ease-in-out;
}
.button:hover {
color: #fff;
background-color: #000;
}
<a href="ProjectPage.html" class="button">projec<span style="letter-spacing:0px;">t</span</a>
推荐阅读
- esp8266 - ESP32(DOIT DevKit)如何通过 mDNS 在同一个 LAN 中找到另一台主机?
- arrays - 在 let 常量数组中初始化并存储对象的 N 个实例?
- ios - 错误的 Module-Swift.h 标头是通过导入到自身生成的
- c++ - VkCmdPipelineBarrier() 不转换图像布局可能是什么情况
- c# - 通过过滤非按字段分组
- java - Netbeans 无法建立到 jdbc 的连接
- reactjs - 组件已声明但从未使用
- javascript - 在 JavaScript 中:为什么不将标准属性的 DOM 属性设置为空字符串,像 Element.removeAttribute() 那样删除属性?
- linux-kernel - 启用 PTI 时的用户空间 CR3 值
- c# - 当我使用 [HttpGet("public-profile/{avatarName}")] 时如何在 asp.net-core 中 RedirectToAction