gpt4 book ai didi

html - 按钮不在 div 内

转载 作者:搜寻专家 更新时间:2023-10-31 08:18:58 24 4
gpt4 key购买 nike

我有一个 <div>和一个 <button> , 但由于某种原因,按钮不会留在 div 中。

我已经尝试清除 div,以及 float: left但它没有帮助。

我还添加了 padding到 div 的底部,但我认为这不是解决方案。

我的代码:

<div class="service-text text2">  
<p>
this is some text
</p>
<a href="" class="button-learn centered"><i class="fa fa-credit-card" style="padding-right:10px;"></i> Learn More</a>

</div>

JSFiddle

最佳答案

通常父 div 将其高度自动设置为其子高度,但您分配给 button-learn 的填充导致了问题。

你只需要在你的 anchor 标签上设置display:inline-block;

内联 block 元素作为内联元素放置(与相邻内容在同一行),但它的行为类似于 block 元素。

.button-learn {
margin: 2px;
position:relative;
text-align: center;
border-radius:4px;
text-decoration: none;
font-family:'PT Sans',helvetica;
background: #69c773;
display:inline-block;
font-size: 17px !important;
padding: 10px 10px 10px 10px;
color: #FFF;
}

Here is fiddle

关于html - 按钮不在 div 内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20757646/

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