Bootstrap buttons not centering as expected [duplicate] - html

This question already has answers here:
How to vertically and horizontally center this text inside bootstrap4 columns? [duplicate]
(4 answers)
Bootstrap Center Vertical and Horizontal Alignment
(17 answers)
Bootstrap 4, How do I center-align a button?
(10 answers)
Closed 5 years ago.
I have this column in my Bootstrap grid:
<div class=col-sm-2>
<div class="w-75 mx-auto">
<br><a class='button btn btn-outline-dark' href='{% url "elections:new_post" %}'>New Post</a><br><br>
<a class='button btn btn-outline-dark' href='{% url "elections:new_image" %}'>New Image</a><br><br>
<div class='card'>
<div class='card-body'>
<p>Test</p>
</div>
</div>
</div>
</div>
Because of the mx-auto, I would expect everything within those div tags to be centered, but the buttons are anchored to the left margin, as is the card and the text within the card.
How do I center the buttons and the card?

Related

Show a text in center location before an image [duplicate]

This question already has answers here:
How can I vertically align elements in a div?
(28 answers)
Closed 1 year ago.
I have this HTML:-
<hr>
<div style='display:flex;align-items:center'>
<span style=''><b>Device and Operating System Selection</b></span>
<img style='height:200px;width:120px'src='https://****.sharepoint.com/sites/HomeOffice/en-ca/Forms/SiteAssets/bc756161-82b9-4c40-ae98-e73d54597cbe.jpg'/><br/>
</div>
We offer 2 types of devices
where the result will be as follow:-
[![enter image description here][1]][1]
while i am trying to show the text in the middle of the picture and not on top of item , as follow:-
You just have to change add justify-content: center;
that will align the text in center vertically.
align-items:center; is to align the items center horizontally.
<div style='display:flex;align-items:center;justify-content: center;'>
<span style=''><b>Device and Operating System Selection</b></span>
<img style='height:200px;width:120px'
src='https://****.sharepoint.com/sites/HomeOffice/en-ca/Forms/SiteAssets/bc756161-82b9-4c40-ae98-e73d54597cbe.jpg' /><br />
</div>
Easy ;D
<hr>
<div style="display:flex;align-items:center;">
<span><b>Device and Operating System Selection</b></span>
<img style="height:200px;width:120px" src="https://****.sharepoint.com/sites/HomeOffice/en-ca/Forms/SiteAssets/bc756161-82b9-4c40-ae98-e73d54597cbe.jpg"><br>
</div>
We offer 2 types of devices
you can assign align-self style to your span
<div style='display:flex;align-items:center'>
<span style='align-self:center; margin-right:10px;'><b>Device and Operating System Selection</b></span>
<img style='height:200px;width:120px'src='https://i.gadgets360cdn.com/products/large/iqoo-3-db-386x800-1582613523.jpg'/><br/>
</div>
We offer 2 types of devices

How can I centre align an item and right align an item within a HTML navigation bar whilst leaving the left empty? [duplicate]

This question already has answers here:
Center one and right/left align other flexbox element
(11 answers)
Closed 2 years ago.
Hopefully this diagram better explains my goal:
This navigation bar is also responsive; the social glyphs collapse into hamburger menu. When this happens, I would like the title to remain centred, although I can probably do this myself.
I recommend you use bootstrap to have a better layout.
for example for you, can use this:
<div class="container">
<nav class="row">
<div class="col-lg-3">
<div class="social-gylph">Twitter</div>
<div class="social-gylph">Facebook</div>
</div>
<div class="col-lg-6">
Website Title
</div>
<div class="col-lg-3">
<!-- nothing at this moment -->
</div>
</nav>
</div>
look more at: Bootstrap Layout

Center element in a responsive row [duplicate]

This question already has answers here:
Align 3 unequal blocks left, center and right
(4 answers)
Closed 2 years ago.
I have a row with several elements (left, center and right).
My problem is that the element in the center is not centered at the level of the screen but at the level of the row.
How can I center that element at the screen level?
When I reduce the screen (mobile) the row gains a horizontal scroll, but it is aligned to the left. Is there a way to always align it to the center and keep it responsive?
DEMO
code
<span style="width:100%; justify-content:center; display:flex">Center!!</span>
<div class="d-flex justify-content-between flex-nowrap myrow">
<div>
<span style="margin-right:10px">align me in left</span>
<span>align me in left</span>
</div>
<div>
<span>align me in center</span>
</div>
<div>
<span>align me in right</span>
</div>
</div>
Look at this example. Maybe it help you demo

Bootstrap Columns with vertically aligned text [duplicate]

This question already has answers here:
How to vertically center a container in Bootstrap?
(10 answers)
Vertically center element with Bootstrap 3
(1 answer)
vertical-align with Bootstrap 3
(26 answers)
Closed 5 years ago.
I have 2 bootstrap col-md-6 columns that one has an image in and the other has a p tag in it with a paragraph of text. how would i dynamically vertically align the text so its perfect compared to the image next to it, code below
<div class="col-md-6">
<img class="img-responsive" src="https://picsum.photos/550/430" >
</div>
<div class="col-md-6">
<p>text goes here</p>
</div>
i also need to be able to do the same thing with a column that may have 3 tags in it so a h3 p and an a tag.
If you are using V4 of bootstrap you can simply rely on some class utilities and use align-items-center to achieve this:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<div class="container">
<div class="row align-items-center">
<div class="col">
<img class="img-responsive" src="https://lorempixel.com/400/200/">
</div>
<div class="col">
<p>text goes here</p>
</div>
</div>
</div>

How to center content within columns on Bootstrap 3 [duplicate]

This question already has answers here:
Bootstrap: How to center align content inside column? [duplicate]
(2 answers)
Closed 6 years ago.
I have this code:
<div class="article-quiz-content.container">
<div class="row">
<div class="col-xs-6.quiz-cols">
<div class="true-placeholder">
<a class=icon-true-shape amenitie_icon" href="#" data-answer="true">
</div>
</div>
<div class=col-xs-6.quiz-cols">
<div class="false-placeholder">
<a class="icon-false-shape amenitie_icon" href="#" data-answer="false">
</div>
</div>
</div>
</div>
Which leads to this:
I need those icons to be in the center of the columns.
Suggestions?
Just add class text-center to your columns (.col-xs-6)
Reference: https://getbootstrap.com/css/#type-alignment
EDIT: after you changed markup you need to add it to placeholder divs
You can do something like this in your css:
.quiz-cols{
text-align: center;
}
.amenitie_icon{
display: inline-block;
}
Inline-block element float to center if container has text-align: center