【发布时间】:2020-09-14 07:38:30
【问题描述】:
我有一个按钮,无论我做什么,它都会自动在左侧和右侧添加填充,我似乎无法减少。
我尝试过使用 max-width 但这只会使按钮移动到页面的左侧
.hero-container-2 {
background-color: #214CCE;
display: inline-block;
margin-top: 150px;
padding: 150px;
}
.hero-container-2 p {
display: inline-block;
color: #ffffff;
text-align: center;
line-height: 2;
margin-bottom: 50px;
}
.buttom {
border: solid 2px #ffffff;
text-align: center;
color: #ffffff;
cursor: pointer;
padding: 15px 40px;
font-family: 'PT Mono', monospace;
text-transform: uppercase;
letter-spacing: 1px;
}
<div class="hero-container-2">
<span id="contactus"></span>
<p><span id="contactus">Itching to ask us a question about the club? Want to pick our brains about training, competing or joining? (We usually react quickly, but it might take us a handful of days to reply).</span></p>
<div class="buttom">
<span id="contactus">Contact Us</span>
</div>
</div>
【问题讨论】:
-
你添加了 padding: 15px 40px;表示左右 40px 的边距
-
添加宽度按钮类
width: 120px;并减少填充 -
你的意思是你希望按钮是页面的全宽(蓝色区域)?如果是这种情况,您为父容器设置了 150 像素的填充,这也会影响按钮
-
您为什么使用
span作为按钮?你没有使用正确的工具来完成这项工作。至少我会考虑一个锚标签。您的提示文本Itching to ask....也与您的按钮具有相同的类 (buttom??)。 -
这能回答你的问题吗? How to set the size of button in HTML