Vertical align a Row bootstrap Full Page - html

<div class="container">
<div class="row">
<div class="col-lg-4 col-sm-6"><div class="text-center"><a class="btn btn-default btn-lg" href="#" role="button">Sell</a></div></div>
<div class="col-lg-4 col-sm-6"><div></div></div>
<div class="col-lg-4 col-sm-12"><div class="text-center"><a class="btn btn-default btn-lg" href="#" role="button">Buy</a></div></div>
</div>
</div>
Ok so iam wanting the 2 buttons next to eachother as they are but want them both in the middle of the screen (Vertically)

Hey try setting the columns text-align left and right like this:
This will make 2 columns and format the left column as text-right and the right column as text left, which will bring them together in the center of the screen:
<div class="container">
<div class="row">
<div class="col-xs-6 text-right">
<a class="btn btn-default btn-lg" href="#" role="button">Sell</a>
</div>
<div class="col-xs-6 text-left">
<a class="btn btn-default btn-lg" href="#" role="button">Buy</a>
</div>
</div>
</div>

From this refference, you can check this out:
<div class="outer">
<div class="middle">
<div class="inner">
<a class="btn btn-default btn-lg" href="#" role="button">Sell</a>
<a class="btn btn-default btn-lg" href="#" role="button">Buy</a>
</div>
</div>
</div>
CSS:
.outer {
display: table;
position: absolute;
height: 100%;
width: 100%;
}
.middle {
display: table-cell;
vertical-align: middle;
}
.inner {
text-align:center;
margin-left: auto;
margin-right: auto;
}
Codepen link: http://codepen.io/anon/pen/zGmagX

Related

How to use display:block properly with buttons in css?

When I use display:block it doesn't want to work which was working before. When I inspect it shows me strike through on display:block. Now the buttons are positioned on the right side of the col, I'd need them to be positioned in the middle under the image.
html
<div class="sectionLight">
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-12 col-lg-4">
<img class="img-fluid imgCenter" src="images/square.png">
<div class="row">
<div class="col-sm-12">
<button type="button" class="btn btn-danger btn-lg btnCenter" data-toggle="modal" data-target=".square-modal-lg">Prime</button>
</div>
</div>
</div>
<div class="col-sm-12 col-lg-4">
<img class="img-fluid imgCenter" src="images/fibo.png">
<div class="row">
<div class="col-sm-12">
<button type="button" class="btn btn-danger btn-lg btnCenter" data-toggle="modal" data-target=".fibo-modal-lg">Fibo</button>
</div>
</div>
</div>
<div class="col-sm-12 col-lg-4">
<img class="img-fluid imgCenter" src="images/square_copy.png">
<div class="row">
<div class="col-sm-12">
<button type="button" class="btn btn-danger btn-lg btnCenter" data-toggle="modal" data-target=".prime-modal-lg">Square</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS
.btnCenter {
display: block;
margin: auto;
margin-top: 15px;
margin-bottom: 20px;
width: 50%;
}
You probably have included another css script that overwrites your current one.
You can try to make it !important. If that doesnt work, you might have to make your selector more spesific than the one currently overwriting it.
.btnCenter {
display: block !important;
margin: auto;
margin-top: 15px;
margin-bottom: 20px;
width: 50%;
}
You can debug this in the dev-tools. See the example image below:
In this example, primary.css is higher in the css hierarchy (meaning the file primary.css is included later than stacks.css) Therefore, it will overwrite the selector.

Express JS - unable to center text in a DIV in a pug template with Bootstrap

I am working on an Express JS web app based on Bootstrap 4 styling as front-end.
No custom stylesheet is involved.
My HTML with Bootstrap 4 styling:
<div class="container">
<div class="row text-center">
<div class="col-sm-6">
<div class="grid-container">
<div><a class="btn btn-primary btn-lg btn-block" href="items/addItem">Add a New Item</a></div>
</div>
</div>
<div class="col-sm-6">
<div class="grid-container">
<div><a class="btn btn-primary btn-lg btn-block" href="items/showItemList?status=0">Originated items</a></div>
</div>
</div>
<div class="col-sm-6">
<div class="grid-container">
<div><a class="btn btn-primary btn-lg btn-block" href="items/showItemList?status=1">Equipment Catelogue</a></div>
</div>
</div>
<div class="col-sm-6">
<div class="grid-container">
<div><a class="btn btn-primary btn-lg btn-block" href="items/showItemList?status=4">Items removed from service</a></div>
</div>
</div>
<div class="col-sm-6">
<div class="grid-container">
<div><a class="btn btn-primary btn-lg btn-block" href="items/showItemList?status=3">Items Under Evaluation</a></div>
</div>
</div>
<div class="col-sm-6">
<div class="grid-container">
<div><a class="btn btn-primary btn-lg btn-block" href="items/showItemList?status=5">Evalutaion Completed but not proceed</a></div>
</div>
</div>
</div>
</div>
I would need to center the text in each DIV element in the grid-container. However, they are all top aligned as below.
You are looking for a vertical-align, and there are multiple ways to get this done.
Here is one of them
div.center.middle {
background: blue;
text-align: center;
vertical-align: middle;
border-radius: 5px;
width: 150px;
height: 85px;
display: table-cell;
}
<div class="center middle">
Test text
</div>
Note that in order for the vertical-align: center to work I had to set the display: table-cell;.

Horizontal align center with offset in Bootstrap 3

I have a bootstrap 3 based layout, with two columns, how can I make sure the text in the second aligns with the center (horizontal) of the page?
HTML:
<div class="row spaced">
<div class="col-sm-2 text-center">
<img src="Images/picture.png" alt="Image" height="100%" width="100%">
</div>
<div class="col-sm-10 text-center horizontal-center">
<h1 class="text-box text-center horizontal-center">Are you interested?</h1>
<button type="button" class="btn btn-primary btn-lg outline text-center">Find Out More</button>
</div>
</div>
CSS:
.horizontal-center {
display: inline-block;
vertical-align: middle;
text-align: center;
float: none;
}
JSFiddle
You can pull the image left and take it out of the container, then make the div 12 so it will use the whole screen
<div class="col-sm-2 pull-left">
<img src="Images/picture.png" alt="space taking image to push other columns off center" height="100%" width="100%">
</div>
<div class="container">
<div class="row spaced">
<div class="col-sm-12 text-center horizontal-center">
<h1 class="text-box text-center horizontal-center">Are you interested to find out more? Then click the button below.</h1>
<button type="button" class="btn btn-primary btn-lg outline text-center">Find Out More</button>
</div>
</div>
</div>
https://jsfiddle.net/ygznu3gy/

Boostrap/CSS Responsive vertically centered

I have 3 <a> with the btn bootstrap class on it.
I found how to center those horizontally and vertically with the above code
HTML
<div class="row row-centered ">
<div class="vertically-centered">
<div class="col-xs-12 col-sm-12">
<a class="btn btn-lg btn-default btn-primary col-centered col-xs-3 col-sm-3 col-md-3" href="#">Prepare</a>
<a class="btn btn-lg btn-default btn-primary col-centered col-xs-3 col-sm-3 col-md-3" href="#" style="margin-left: 100px; margin-right: 100px;">Handover</a>
<a class="btn btn-lg btn-default btn-primary col-centered col-xs-3 col-sm-3 col-md-3" href="#">Tuto</a>
</div>
</div>
</div>
CSS
.btn-lg{
padding-top: 50px;
padding-bottom: 50px;
padding-left: 10px;
padding-right:10px;
}
.row-centered {
text-align: center;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
font: 0/0 a;
}
.row-centered:before {
content: ' ';
display: inline-block;
vertical-align: middle;
height: 100%;
}
.vertically-centered {
vertical-align: middle;
display: inline-block;
width: 100%;
}
.col-centered {
display: inline-block;
float: none;
}
It works as expected when the screen is wide enough
But it is failing when the screen is smaller (width) than 830px
EDIT
I change the HTML and CSS
HTML MODIFIED
<div class="row row-centered ">
<div class="vertically-centered">
<div class="col-xs-12 col-sm-4 col-md-4">
<a class="btn btn-lg btn-default btn-primary" href="#">Prepare</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4">
<a class="btn btn-lg btn-default btn-primary" href="#">Handover</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4">
<a class="btn btn-lg btn-default btn-primary" href="#">Tuto</a>
</div>
</div>
</div>
CSS MODIFIED
.btn-lg{
padding-top:30px;
padding-bottom:30px;
width:100%;
}
.row-centered {
text-align: center;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
font: 0/0 a;
}
.row-centered:before {
content: ' ';
display: inline-block;
vertical-align: middle;
height: 100%;
}
.vertically-centered {
vertical-align: middle;
display: inline-block;
width: 100%;
}
.col-centered {
display: inline-block;
float: none;
}
Now my problem is that I button are aligned above each other (which is nice) but they are going under my nav-background
Change the margin on the middle button to a percentage value:
<a class="btn btn-lg btn-default btn-primary col-centered col-xs-3 col-sm-3 col-md-3" href="#" style="margin-left: 5%; margin-right: 5%;">Handover</a>
I think it is because you use a margin before and after the middle link. What I try to do is solve it with empty columns
<div class="row row-centered ">
<div class="vertically-centered">
<div class="col-xs-12 col-sm-12">
<a class="btn btn-lg btn-default btn-primary col-centered col-xs-3 col-sm-3 col-md-3" href="#">Prepare</a>
<a class="btn btn-lg btn-default btn-primary col-centered col-xs-1 col-sm-1 col-md-1" href="#"></a>
<a class="btn btn-lg btn-default btn-primary col-centered col-xs-3 col-sm-3 col-md-3" href="#">Handover</a>
<a class="btn btn-lg btn-default btn-primary col-centered col-xs-1 col-sm-1 col-md-1" href="#"></a>
<a class="btn btn-lg btn-default btn-primary col-centered col-xs-3 col-sm-3 col-md-3" href="#">Tuto</a>
</div>
</div>
</div>
The problem was that the nav was a custome class instead of the navbar class from boostrap

jumbotron text on left image on right

I have a Jumbotron with 2 divs, one to display text and one for an image. It works fine on very small and large screen but image overflows badly on medium to small. I would like the image to either shrink to suit or else vanish completely.
I have not made any changes to any #media.
Here is the code I have:
<div class="jumbotron">
<div class="container">
<div class="row">
<div class=" col-md-6 col-sm-12" >
<h1>Dive Gweedore </h1>
<p>A place of wonder and crystal clear water</p>
<p><a class="btn btn-primary btn-sm" role="button">
Durability</a>
<a class="btn btn-primary btn-sm " role="button">
Strength</a>
<a class="btn btn-primary btn-sm" role="button">
Brilliance</a>
</p>
</div>
<div class=" col-md-6">
<img class="showcase-image" src="http://localhost/shop/image/cache/catalog/hand.png">
</div>
</div>
</div>
</div>
Insert Bootstrap img-responsive class in your image.
.img-responsive {
display: block;
height: auto;
max-width: 100%;
}