Align a column element at the top-right

Asked

Viewed 903 times

1

I have a checkbox within a column and would like to put it at 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 class "Right Line" I tried some things like:

float: right;

I also tried to:

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

But nothing seems to change much.

My element:

inserir a descrição da imagem aqui

I also tried the child element (col-12,col-Sm-9), but it doesn’t change much.

1 answer

1


Apparently you are putting the class in the wrong element... Actually I think your Grid structure of MD Bootstrap is a little strange... I made simple changes in the Grid organization and used basically align-text:right and vertical-aligh:top to align the label since she’s an element of the 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>
    <script src="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>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.bundle.min.js"></script>
</body>
</html>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.