如何使用bootstrap 4将按钮和复选框移动到右侧?

时间:2017-08-14 10:45:41

标签: css twitter-bootstrap button checkbox alignment

我用Bootstrap 4做了这个,我想把按钮和复选框移到右边,但我真的不知道怎么做,有人可以帮助我吗?

enter image description here

HTML代码:

<div class="col-8">
<div class="form-group" style="text-align:right">
    <textarea class="form-control" id="exampleFormControlTextarea1" rows="3" placeholder="Lascia anche tu una dedica sul profilo di @xdekus">
    </textarea>
    <div class="form-row align-items-center" style="margin-top:1%;text-align:right">
        <div class="col-auto">
            <button type="submit" class="btn" style="background-color: #5EBD63; color:white; cursor:pointer; margin-top:1%;">Invia</button>
        </div>
        <div class="col-auto">
            <label class="custom-control custom-checkbox" style="margin-bottom: 0px;">
                <input type="checkbox" class="custom-control-input">
                <span class="custom-control-indicator"></span>
                <span class="custom-control-description">Lascia la dedica in forma anonima.</span>
            </label>
        </div>
    </div>
</div>

2 个答案:

答案 0 :(得分:0)

尝试以下代码

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="col-8">
<div class="form-group" style="text-align:right">
    <textarea  class="form-control" id="exampleFormControlTextarea1" rows="3" placeholder="Lascia anche tu una dedica sul profilo di @xdekus"></textarea>
    <div class="form-row align-items-center" style="margin-top:1%;text-align:right">
        <div class="col-auto">
            <button type="submit" class="btn" style="background-color: #5EBD63; color:white; cursor:pointer; margin-top:1%;">Invia</button>
        
            <label class="custom-control custom-checkbox" style="margin-bottom: 0px;">
                <input type="checkbox" class="custom-control-input">
                <span class="custom-control-description">Lascia la dedica in forma anonima.</span>
            </label>
            </div>
    </div>
</div>

</div>
</body>
</html>

答案 1 :(得分:0)

&GT;

<div class="col-8">
>    <div class="form-group" style="text-align:right">
>        <textarea class="form-control" id="exampleFormControlTextarea1" rows="3" placeholder="Lascia anche tu
> una dedica sul profilo di @xdekus">
>        </textarea>
>        <div class="form-row align-items-center" style="margin-top:1%;text-align:right">
>             <div class="col-auto">
>                  <label class="custom-control custom-checkbox" style="margin-bottom: 0px;">
>                      Lascia la dedica in forma anonima. -     
>                      <input type="checkbox" class="custom-control-input">
>                  </label>
>             </div>
>             <div class="col-auto">
>                  <button type="submit" class="btn" style="background-color: #5EBD63; color:white; cursor:pointer;
> margin-top:1%;">Invia</button>
>             </div>
>        </div>
>   </div> 
</div>