Align element of a column in the top-right

1

I have a checkbox inside a column and would like to put it in the top-right.

My template:

<div class="row">
   <div class="col-11">
      <h4 class="card-title">Bolsa camuflada</h4>
   </div>
   <div class="col-1 alinhaDireita">
      <div class="col-12 col-sm-9">
         <div id="checkpossuiwhats" class="custom-control custom-checkbox check">
            <input type="checkbox" id="checkwhats" name="checkwhats" class="custom-control-input">
            <label class="custom-control-label" for="checkwhats"></label>
         </div>
      </div>
   </div>
</div>

In this "right-align" class I tried some things like:

float: right;

I've also tried:

position: absolute;
top: 0px
right: 0px

But nothing seems to change much.

My element:

I also tried the child element (col-12, col-sm-9), but it does not change much.

    
asked by anonymous 23.10.2018 / 22:34

1 answer

1

Apparently you're putting the class in the wrong element ... Actually I think your MD Bootstrap Grid structure is kind of weird ... I made simple changes to the Grid organization and basically used align-text:right and vertical-aligh:top to aligns label since it is an element of type inline

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Font Awesome -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Bootstrap core CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.5.13/css/mdb.min.css" rel="stylesheet">
<style>
.row, .d-flex{
    display: flex;
    justify-content: center;
}
@media only screen and (max-width: 566px) {
    .d-flex{
        flex-direction: column;
        align-items: center;
    }
}

#checkpossuiwhats {
    text-align: right;
}
#checkpossuiwhats label {
    margin-bottom: 100%;
    vertical-align: top;
}

</style>
</head>
<body>
    
    <div class="row">
        <div class="col-11">
           <h4 class="card-title">Bolsa camuflada</h4>
        </div>
        <div id="checkpossuiwhats" class="col-1 custom-control custom-checkbox check">
            <input type="checkbox" id="checkwhats" name="checkwhats" class="custom-control-input">
            <label class="custom-control-label" for="checkwhats"></label>
        </div>
    </div>

    
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.bundle.min.js"></script>
</body>
</html>
    
23.10.2018 / 23:15