By using Twitter Bootstrap 3.2.0 and a very nice snippet, I've created a menu-box with multiple choices.
For each menu item there is a label and a short description, as shown in figure below:
You could find an example with the code on JSfiddle.
Now, I'd like to:
Align menu-item content on middle (regarding the vertical-alignment);
Align the submit button on bottom-right.
Someone can suggest me how to do that?
1. Align menu-item content on middle (regarding the vertical-alignment):
I've recently used this excellent tutorial by #beaver82minimit that allows to create equal height columns bootstrap style: http://www.minimit.com/articles/solutions-tutorials/bootstrap-3-responsive-columns-of-same-height
You can use it like this:
<div class="container container-xs-height">
<div class="row row-xs-height">
<div class="col-xs-6 col-xs-height"></div>
<div class="col-xs-3 col-xs-height col-top"></div>
<div class="col-xs-2 col-xs-height col-middle"></div>
<div class="col-xs-1 col-xs-height col-bottom"></div>
</div>
</div>
With the class col-middle you can center your content vertically.
2. Align the submit button on bottom-right
a) Add class bottom-right to the button and remove the wrapping <p>
<button type="button" class="btn btn-primary btn bottom-right" style="margin: 20px 0 0 0;"><span class="glyphicon glyphicon-log-in"></span> Submit</button>
b) Add this to your stylesheet:
.bottom-right {
position: absolute;
right: 0;
bottom: 0;
}
To prevent tab content to overlap with button, add padding-bottom to tab-content div:
div.bhoechie-tab-content{
background-color: #ffffff;
padding-left: 20px;
padding-top: 10px;
padding-bottom: 54px;
}
Here is a demo: http://jsfiddle.net/LaBZP/3/
List-group-item vertical aligning middle:
.text-center {
display: table;
width: 100%;
}
.text-center > div {
display: table-cell;
vertical-align: middle;
}
Add divs under list-group-item to markup:
<a href="#" class="list-group-item idp-group-item text-center">
<div>
<strong>Label B</strong><br/>Label B Desc
</div>
</a>
Demo: http://jsfiddle.net/LaBZP/4/
Related
My HTML
<div class="col-sm-5">some content</div>
<div class="col-sm-1">
<button class="fa fa-plus-circle" type="button"></button>
</div>
<div class="col-sm-6">some other content</div>
My css
position: absolute;
bottom: 10px;
left: 0px;
right: 0px;
color: #fff;
margin: 0px auto;
text-align: center;
font-size: 40px;
I want to make the plus button to come down. By the above codes it will come to the exact correct position however col-sm-6 sticks itself to the left because the button is absolute.
I'm using bootstrap 3
How can I fix this issue?
Thanks
Maybe try this.
<div class="row">
<div class="col-sm-5">some content</div>
//put all other content you want in a grid-1 here
</div>
<div class="row">
<div class="col-sm-12">
<button class="fa fa-plus-circle" type="button"></button>
</div>
<div class="row">
<div class="col-sm-6">some other content</div>
//content for the remaining grid-2
This should probably make your design as
-- Grid 1
-- Plus Circle
-- Grid 2
The mistake you are doing is that you aren't following bootstrap grid convention here.
Also, For some reason, you haven't described class, ID, Tag on which you have added CSS.
Lastly, Make sure your CSS is below bootstrap CSS.
EDIT: This was my issue
bootstrap 4 center-block unable to center
I cannot for the life of me figure out how to properly align this image inside a bootstrap column. You can see how there is a big whitespace gap to the right of the image between the border of the image and the padding for the div column the image is in.
I have a row with 3 columns. I want the 2 images to be properly aligned in the page. this would be more easily accomplished if this awkward whitespace did not appear.
For now, I've added the below as a (not-so) quick fix.
.right-img {
padding-left: 45px;
}
I have tried several avenues including
class="center-block"
and removing
float-left
from the show-image class and flexbox and display-block and all the align properties and ensuring I have a container above the row.
I would really appreciate it if someone could help with the issue.
Here is the HTML:
<div class="container">
<div class="row">
<div class="col-lg-5 show-image">
<img class="img-responsive rounded head-img" src="{{ url_for('static', filename='#') }}" alt="Image Failed to Load">
<div class="hover-buttons">
<button type="submit" class="btn btn-danger btn-sm">Why Join?</button>
<button type="submit" class="btn btn-danger btn-sm">How It Works</button>
</div>
</div>
<div class="col-lg-2" id="with-container">
<h1 class="my-4 text-center">WITH</h1>
</div>
<div class="col-lg-5 show-image right-img">
<img class="img-fluid rounded head-img" src="{{url_for('static', filename='#')}}" alt="Image Failed to Load">
<div class="hover-buttons left-buttons">
<button type="submit" class="btn btn-danger btn-sm">Why Join?</button>
<button type="submit" class="btn btn-danger btn-sm">How It Works</button>
</div>
</div>
</div>
</div>
And here is the styling:
div {
border: 1px dashed red;
}
.head-img {
width: 400px;
height: 287px;
}
#with-container {
display: flex;
justify-content: center;
align-items: center;
}
div.show-image {
position: relative;
float: left;
}
div.show-image:hover img{
opacity:0.5;
}
div.show-image:hover .hover-buttons {
display: inline-block;
}
.hover-buttons {
position: absolute;
display:none;
}
div.show-image .hover-buttons {
top: 75%;
left: 12%;
}
div.show-image .left-buttons {
top: 75%;
left: 19%;
}
You could apply the following bootstrap helper class to the parent div:
text-center
Which should horizontally align the image for you. The full div class structure should look like the following:
<div class="col-lg-5 show-image text-center">
Further reading: https://v4-alpha.getbootstrap.com/utilities/typography/#text-alignment
How can I center 2 buttons vertically in my view?
For example:
<div class="container">
<div class="row">
<div class="col-md-5">
<h4>My List</h4>
<div style="height:400px; overflow-y:auto">
<ul>
// List of checkboxes
</ul>
</div>
</div>
<div class="col-md-2">
<input type="button" id="btnAddField" class="btn btn-primary" value="Add" />
<input type="button" id="btnRemoveField" class="btn btn-primary" value="Remove" />
</div>
<div class="col-md-5">
<h4>Selected Fields</h4>
// This will contain the list selected from the checkboxes.
</div>
</div>
</div>
I want the buttons in column 2 to be centered in relation to column 1 (which in this case I made height of 400px.
Try css Line Height. Hope it will help.
vertical-align: middle;
line-height: 400px;
If you can use flexbox, something like this would do what you want (using your existing classes):
.row {
display: flex;
[class^="col"] {
float: none;
flex-shrink: 0;
margin: auto 0;
}
}
You can add new class on row that will use Flexbox and vertically center items with align-items: center when width is > 992px which is breakpoint of md DEMO
#media(min-width: 992px) {
.flex-row {
display: flex;
align-items: center;
}
}
How do you go about making a navbar in Bootstrap that is non-collapsable and has a glyphicon button on the left without a border, text in the center and text on the right?
I know you can use pull-left and pull-right to move items to the left and to the right but when I try to add a glyphicon button to the navbar, it will become tiny and create a border around it.
Example of what I'm trying to accomplish:
Instead pull-left-right, use text-left-center-right. Try this:
HTML:
<div class="navbar navbar-fixed-top">
<div class="col-xs-4 text-left">
<i class="fa fa-chevron-left"></i>
</div>
<div class="col-xs-4 text-center">insertnamehere's room</div>
<div class="col-xs-4 text-right">0 -1</div>
</div>
CSS:
* {
font-size: 20px;
}
.pull-right {
text-align:right;
}
.navbar {
padding: 10px;
}
See Example.
I am working on a photo gallery, each thumbnail is in its own DIV and floated to the left in a containing DIV. It has been displaying properly up until vertical thumbnails entered the equation. Now, when the next row should start, the first item of the following row is to the left of the last vertical DIV (thumbnail), rather than flush to the left of the containing DIV.
alt text http://tapp-essexvfd.org/images/capture1.jpg
Here is the CSS:
#galleryBox {
width: 650px;
background: #fff;
margin: auto;
padding: 10px;
text-align: center;
overflow: auto;
}
.item {
display: block;
margin: 10px;
padding: 20px 5px 5px 5px;
float: left;
background: url('/images/content_bottom.png') repeat-x scroll bottom #828282;
}
and the HTML:
<div id="galleryBox" class="ui-corner-all">
<div id="file" class="ui-corner-all">
<form name="uploadPhoto" id="uploadPhoto" method="post" action="" enctype="multipart/form-data">
<p><label for="photo">Photo:</label><input type="file" name="photo" id="photo"/></p>
<p><label for="caption">Caption: <small>Optional</small></label><input type="text" id="caption" name="caption"/></p>
<p align="center"><input type="submit" value="Upload" name="send" id="send" class="addButton ui-state-default ui-corner-all"/></p>
</form>
<a name="thumbs"></a>
</div>
<div class="item ui-corner-all">
<a href="http://tapp-essexvfd.org/gallery/photos/201004211802.jpg" class="lightbox" title="test1">
<img src="http://tapp-essexvfd.org/gallery/photos/thumbs/201004211802_thumb.jpg" alt="test1"/></a><br/>
<p><span class="label">test1</span></p>
</div>
<div class="item ui-corner-all">
<a href="http://tapp-essexvfd.org/gallery/photos/201004211803.jpg" class="lightbox" title="test3">
<img src="http://tapp-essexvfd.org/gallery/photos/thumbs/201004211803_thumb.jpg" alt="test3"/></a><br/>
<p><span class="label">test3</span></p>
</div>
</div>
You can use Inline-Blocks as described in this article:
The Inline-Block Thumbnail Gallery
The article solves the same exact problem you are having with thumbnails.
I also found this simple example using inline-block thumbnails. Note how the thumbnails wrap nicely and remain vertically aligned within their line.
UPDATE:
Here is another detailed article that tackles this problem with the inline-block:
Cross-Browser Inline-Block
As you can notice from these articles, it is a bit tricky to make it work cross-browser.
Two options:
Set a maximum height for the thumbnail DIVs, so that they layout correctly, regardless of whether they are horizontal or vertical.
Use "clear: left" to reset the float on the thumbnail DIV next to the vertical.
The default behavior appears correct, based on what happens when text flows around a floated DIV. Based on what you're trying to do, I would choose option #1.
you could try using css table displays for your divs...
ie.
#galleryBox {
display: table;
...
}
.item {
display: table-cell;
...
}
.row {
display: table-row;
}
so you'd have to add another div to wrap around the items in each row
<div id="galleryBox">
<div class="row">
<div class="item">image</div>
<div class="item">image</div>
<div class="item">image</div>
<div class="item">image</div>
</div>
<div class="row">
<div class="item">image</div>
<div class="item">image</div>
<div class="item">image</div>
<div class="item">image</div>
</div>
</div>