我想将h3标题和按钮放在同一行
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js" integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div class="container">
<div class="get-quote">
<div class="row">
<div class="col-md-12">
<h3 id="quote">IN HOUSE EMBROIDERY AND HEAT TRASNFER</h3> <button type="button" class="pull-right" class="btn btn-primary">Get Quote</button>
</div>
</div>
</div>
</div>
答案 0 :(得分:1)
尝试:
h3 {
margin: 0;
display: inline-block;
}
button {
float: right;
}
但是,你正在使用 Bootstrap ,所以也许:col-md-6
两者都有?
答案 1 :(得分:0)
你可以使用两个.col-
来将它们放在一行上。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js" integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div class="container">
<div class="get-quote">
<div class="row">
<div class="col-md-10 col-sm-12">
<h3 id="quote">IN HOUSE EMBROIDERY AND HEAT TRASNFER</h3>
</div>
<div class="col-md-2 col-sm-12">
<button type="button" class="btn btn-primary pull-right" class="btn btn-primary">Get Quote</button>
</div>
</div>
</div>
</div>
&#13;
答案 2 :(得分:0)
h3
是出了名的害羞,喜欢孤立自己。通过将style="display:inline-block"
添加到h3
的参数,鼓励他离开并与按钮交朋友。
答案 3 :(得分:0)
只需为display: inline-block;
添加h3
。
h3 {
display: inline-block;
}
<div class="container">
<div class="get-quote">
<div class="row">
<div class="col-md-12">
<h3 id="quote">IN HOUSE EMBROIDERY AND HEAT TRASNFER</h3> <button type="button" class="pull-right" class="btn btn-primary">Get Quote</button>
</div>
</div>
</div>
</div>
答案 4 :(得分:0)
在d-flex
div。
col-md-12
课程
同时在按钮上添加ml-auto
以右对齐按钮
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js" integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div class="container">
<div class="get-quote">
<div class="row">
<div class="col-md-12 d-flex">
<h3 id="quote">IN HOUSE EMBROIDERY AND HEAT TRASNFER</h3>
<button type="button" class="btn btn-primary ml-auto">Get Quote</button>
</div>
</div>
</div>
</div>