Right alignment element in div class with bootstrap 4

I am using angular 2 with Bootstrap 4 and Angular Material . However, I am having problems aligning the elements inside my div container. I want both my button and text aligned on the right side

Here is the code I tried to reproduce as shown in the photo

<div class="container">
  <div class="pull-right">
    <p class="d-inline pull-right">Some text</p>
    <button type="button" class="btn btn-primary pull-right">+</button>
  </div>
</div>

Align Right

I have also tried this solution from https://stackoverflow.com/a/3/29/31

<div class="container">
  <div class="asdf">
    <p class="d-inline pull-right">Some text</p>
    <button type="button" class="btn btn-primary pull-right">+</button>
  </div>
</div>

.asdf {
  margin-left:auto; 
  margin-right:0;
}

Both of these solutions do not move elements to the right. What am I doing wrong?

+3
source share
3 answers

pull-right button p text-right div.container.

, , .

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>



<div class="container text-right">
    <p class="d-inline">Some text</p>
    <button type="button" class="btn btn-primary d-inline">+</button>
</div>
Hide result
+8

. -, . .

HTML:

        <div class="container">
          <div class="row">
            <div class="col-md-12 .asdf">
              <button type="button" class="btn btn-primary pull-right">+</button>
              <p class="pull-right">Some text</p>
            </div>
          </div>
        </div>

CSS-

.asdf {
  margin-left:auto; 
  margin-right:0;
}
0

Bootstrap 4, pull-right float-right.

float-right , , Bootstrap 4 flexbox, display:flex, float-right, , align-self-end ml-auto, , flexbox, , Bootstrap 4.row, Card Nav. ml-auto (margin-left: auto) flexbox .

, text-right - .

Bootstrap 4

0

Source: https://habr.com/ru/post/1016219/


All Articles