【发布时间】:2023-03-06 00:03:02
【问题描述】:
我有一个并排包含 2 个按钮的 div,我希望该 div 通过使用 top 和 left 属性来移动,但不幸的是,当我应用 position: absolute 时,按钮正在新行中呈现。我不希望该按钮在 position: absolute 时出现在新行中。提前致谢。
.btn-primary{
color: #fff;
padding: 0px 7% 0px 5px;
height: 45px;
display: inline-block;
text-align: left;
white-space: nowrap;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
background-image:linear-gradient(#25cdf7, #1144ab);;
border: 1px solid #ccc;
}
.btn-text{
margin-top: 5px;
margin-bottom: 5px;
}
<div>
<a class="btn-primary"><h6 class="btn-text">Subject</h6><h5 class="btn-text">PHYSICS</h5></a>
<i class="fa fa-caret-right" aria-hidden="true" style="font-size: 30px;"></i>
<a class="btn-primary" style="background-image: linear-gradient(#4cad4e,#4cad4e); "><h6 class="btn-text">Topic</h6><h5 class="btn-text">FORCES</h5></a>
</div>
【问题讨论】:
-
你想要的输出是什么?
-
与
position:absolute到该 div 的输出相同 -
将 display: flex 添加到 div 标签。
标签: html css bootstrap-4