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>
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?
pull-right button p text-right div.container.
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>
. -, . .
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; }
Bootstrap 4, pull-right float-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 .
display:flex
align-self-end
ml-auto
, text-right - .
Bootstrap 4
Source: https://habr.com/ru/post/1016219/More articles:Сетка WPF с правилом проверки и зависимостью - c#rendering millions of voxels using three-dimensional textures using three .js - three.jsStack distribution, why extra space? - assemblyBootstrap 4 aligns elements right inside a col div - cssEffectively check if a point is inside a large number of triangles in 2D - algorithmGeneric async Retry с функцией таймаута в С# - c#Cannot get MNIST database via Anaconda / jupyter - scikit-learnSearch for groups of nonzero elements using R - vectorRxJS - debounce event after throttle? - javascriptWebpack 2 with new AureliaPlugin cannot find module at runtime - webpack-2All Articles