I'm trying to place a button on top of a thumbnail image but the button is added after the image, in the caption area.
Here is the code:
<div class="thumbnail">
<img class="img-responsive"alt="300x200" src="network_sec.jpg">
<button class="btn btn-default btn-warning pull-right"><span class="glyphicon glyphicon-user"></span> 10</button>
<div class="caption">
<h3 align="center">Network Security</h3>
<br>
<p>
<button class="btn btn-default btn-danger"><span class="glyphicon glyphicon-wrench"></span> Manage</button>
<button class="btn btn-default btn-danger"><span class="glyphicon glyphicon-eye-open"></span> Preview</button>
<button class="btn btn-default btn-danger"><span class="glyphicon glyphicon-pencil"></span> Edit Info</button>
</p>
</div>
</div>
I'm trying to align the button at the bottom right part of the image. Any suggestions on how can I achieve the desired result?
I would put the image an the button in a new div, then use positioning relative and absolute like this.
HTML
<div class="thumbnail">
<div id="thumb">
<img class="img-responsive"alt="300x200" src="network_sec.jpg">
<button class="btn btn-default btn-warning pull-right"><span class="glyphicon glyphicon-user"></span> 10</button>
</div>
<div class="caption">
<h3 align="center">Network Security</h3>
<br>
<p>
<button class="btn btn-default btn-danger"><span class="glyphicon glyphicon-wrench"></span> Manage</button>
<button class="btn btn-default btn-danger"><span class="glyphicon glyphicon-eye-open"></span> Preview</button>
<button class="btn btn-default btn-danger"><span class="glyphicon glyphicon-pencil"></span> Edit Info</button>
</p>
</div>
</div>
CSS
#thumb
{
position: relative;
width: 300px;
height: 200px;
}
#thumb img
{
z-index: 1;
position: absolute;
width: 300px;
height:200px;
top: 0;
left: 0;
}
#thumb button
{
z-index: 5;
position: absolute;
bottom: 0;
right: 0;
}
Is that what you had in mind?
Related
I wanna make my horizontal buttons fill my modal view.
This is what I made, using this button classes: click here
HTML:
<div class="modal fade" id="usuario_info" abindex="-1" role="dialog" aria-labelledby="myInfoUser" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<center>
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRbezqZpEuwGSvitKy3wrwnth5kysKdRqBW54cAszm_wiutku3R" name="aboutme" width="96" height="96" border="0" class="img-circle">
<h3 class="media-heading" id="bookId"></h3>
</center>
<br>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Subtitle</h3>
</div>
<p class="cuerpo-info-user">Something</p>
</div>
<button type="button" class="btn btn-labeled btn-success">
<span class="btn-label"><i class="fa fa-phone"></i></span>
Call him
</button>
<button type="button button-infousuario" class="btn btn-labeled btn-success">
<span class="btn-label"><i class="fa fa-ban"></i></span>
More information
</button>
<button type="button button-infousuario" class="btn btn-labeled btn-success">
<span class="btn-label"><i class="icon_check"></i></span>
Success
</button>
<button type="button button-infousuario" class="btn btn-labeled btn-danger">
<span class="btn-label"><i class="icon-cancel"></i></span>
Remove him
</button>
<button type="button" class="btn btn-labeled btn-danger button-infousuario">
<span class="btn-label"><i class="icon-trash"></i></span>
Remove everything
</button>
</dsiv>
</div>
</div>
</div><!-- End modal -->
My result:
I tried with:
.button-infousuario{
display:inline-block;
}
but not working.
Thanks for helping!
If I understood you correctly, you can make your buttons fill your modal view by setting their width: 100%. But the text will appear in the center of the button. To prevent that you can set text-align: left
.button-infousuario{
width: 100%;
text-align: left;
}
I have a small div that contains a bootstrap horizontal btn-group. The buttons are wrapping because the div is not wide enough to fit it.
How can I stop this and keep the buttons all horizontal and horizontally centred?
Problem:
How it should look:
<div class="vd-text-widget" style="position: absolute; background-color: #eee; width: 10%; height: 15%; left: 10%; top: 50%">
<div class="btn-group btn-group-lg btn-group-horizontal">
<button class="btn btn-default">
<span class="glyphicon glyphicon-th-list"></span>
</button>
<button class="btn btn-default">
<span class="glyphicon glyphicon-header"></span>
</button>
<button class="btn btn-default">
<span class="glyphicon glyphicon-link"></span>
</button>
<button class="btn btn-default">
<span class="glyphicon glyphicon-font"></span>
</button>
<button class="btn btn-default">
<span class="glyphicon glyphicon-text-size"></span>
</button>
</div>
<p>abbnnb </p>
</div>
Edit: Using display: -moz-box works on firefox. Will look into other browser solutions. Any ideas how to make it horizontally centred?
This worked for me:
<div class="btn-group" style="display: flex">
Change width to 20%
style="position: absolute; background-color: #eee; width: 20%; height: 15%; left: 10%; top: 50%"
Online Demo
OR you can do it by change btn-group-lg to btn-group-sm
You could add white-space: nowrap; to the .vd-text-widget class.
This is my product template file.
<br>
<div>
<div ng-if="SearchText.length<3" ng-repeat="product in pc.ProductService.Products | filter:FilterExpr:true |orderBy:['SubCategoryName','BrandName'] | groupBy:['BrandName']" >
<h2 ng-show="product.group_by_CHANGED">{{product.BrandName}} </h2>
<div class='box'>
<ng-include src="'commonTemplate.html'"></ng-include>
</div>
</div>
<!-- template (common piece of code) -->
<script type="text/ng-template" id="commonTemplate.html">
<div class="BrandName"> <b>{{product.BrandName}}</b> </div>
<div class="ProductName"> {{product.ProductName}} </div>
<br>
<div> <img src="http://localhost/{{ product.ProductImagePath }}" alt="" border=3 height=75 width=75></img> </div>
<div class="ProductVariants">
<select class="form-control btn btn-default btn-xs text-center" ng-init="SelectedVariant = product.Variants[0]" ng-model="SelectedVariant" ng-options="variant.VariantName for variant in product.Variants" ng-change="ChangeVariant(product.ProductID, SelectedVariant.VariantID)"></select>
</div>
<div class="Price">
<strike> {{SelectedVariant.MRP}} </strike> {{SelectedVariant.SellPrice}}
</div>
<div class="AddToCart" ng-if="SelectedVariant.InCart==0">
<a class="btn btn-success btn-sm" ng-click="pc.AddToCart(product.ProductID, SelectedVariant.VariantID)">Add to Cart
<span class="glyphicon glyphicon-plus"></span>
</a>
</div>
<div class="AddToCart" ng-if="SelectedVariant.InCart>0">
<a class="btn btn-default btn-xs" ng-click="pc.PlusItem(product.ProductID, SelectedVariant.VariantID)">
<span class="glyphicon glyphicon-plus"></span>
</a>
<button type="button" class="btn btn-sm btn-info disabled">{{SelectedVariant.InCart}} in cart</button>
<a class="btn btn-default btn-xs" ng-click="pc.MinusItem(product.ProductID, SelectedVariant.VariantID)">
<span class="glyphicon glyphicon-minus"></span>
</a>
</div>
</script>
</div>
Box class is defined like this in CSS:
.box {
margin : 5px;
display : inline-block;
width: 170px;
height: 275px;
background-color: #F5FBEF;
text-align:center;
vertical-align: top;
}
When display my product list look like this:
I want to show products side by side.
Can some one help me how to do that?
EDIT:
After changes suggested by Rachel Gallen, it turn out like this:
I want to display brand name in new line when new brand encounters. rest all looks good.
I put in .ng-repeat:display:inline plus a wrapper
#wrapper {
display: inline!important;
height: 275px;
max-width: 540px;
}
.box {
margin: 5px;
display: inline-block;
width: 170px;
height: 275px!important;
background-color: #F5FBEF;
text-align: center;
float: left;
}
.ng-repeat {
display: inline-block;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div>
<div ng-if="SearchText.length<3" ng-repeat="product in pc.ProductService.Products | filter:FilterExpr:true |orderBy:['SubCategoryName','BrandName'] | groupBy:['BrandName']">
<h2 ng-show="product.group_by_CHANGED">{{product.BrandName}} </h2>
<div id=wrapper>
<div class='box'>
<div class="BrandName"> <b>{{product.BrandName}}</b>
</div>
<div class="ProductName">{{product.ProductName}}</div>
<br>
<div>
<img src="http://localhost/{{ product.ProductImagePath }}" alt="" border=3 height=75 width=75></img>
</div>
<div class="ProductVariants">
<select class="form-control btn btn-default btn-xs text-center" ng-init="SelectedVariant = product.Variants[0]" ng-model="SelectedVariant" ng-options="variant.VariantName for variant in product.Variants" ng-change="ChangeVariant(product.ProductID, SelectedVariant.VariantID)"></select>
</div>
<div class="Price">
<strike> {{SelectedVariant.MRP}} </strike> {{SelectedVariant.SellPrice}}
</div>
<div class="AddToCart" ng-if="SelectedVariant.InCart==0">
<a class="btn btn-success btn-sm" ng-click="pc.AddToCart(product.ProductID, SelectedVariant.VariantID)">Add to Cart
<span class="glyphicon glyphicon-plus"></span>
</a>
</div>
<div class="AddToCart" ng-if="SelectedVariant.InCart>0">
<a class="btn btn-default btn-xs" ng-click="pc.PlusItem(product.ProductID, SelectedVariant.VariantID)">
<span class="glyphicon glyphicon-plus"></span>
</a>
<button type="button" class="btn btn-sm btn-info disabled">{{SelectedVariant.InCart}} in cart</button>
<a class="btn btn-default btn-xs" ng-click="pc.MinusItem(product.ProductID, SelectedVariant.VariantID)">
<span class="glyphicon glyphicon-minus"></span>
</a>
</div>
</div>
<div class='box'>
<div class="BrandName"> <b>{{product.BrandName}}</b>
</div>
<div class="ProductName">{{product.ProductName}}</div>
<br>
<div>
<img src="http://localhost/{{ product.ProductImagePath }}" alt="" border=3 height=75 width=75></img>
</div>
<div class="ProductVariants">
<select class="form-control btn btn-default btn-xs text-center" ng-init="SelectedVariant = product.Variants[0]" ng-model="SelectedVariant" ng-options="variant.VariantName for variant in product.Variants" ng-change="ChangeVariant(product.ProductID, SelectedVariant.VariantID)"></select>
</div>
<div class="Price">
<strike> {{SelectedVariant.MRP}} </strike> {{SelectedVariant.SellPrice}}
</div>
<div class="AddToCart" ng-if="SelectedVariant.InCart==0">
<a class="btn btn-success btn-sm" ng-click="pc.AddToCart(product.ProductID, SelectedVariant.VariantID)">Add to Cart
<span class="glyphicon glyphicon-plus"></span>
</a>
</div>
<div class="AddToCart" ng-if="SelectedVariant.InCart>0">
<a class="btn btn-default btn-xs" ng-click="pc.PlusItem(product.ProductID, SelectedVariant.VariantID)">
<span class="glyphicon glyphicon-plus"></span>
</a>
<button type="button" class="btn btn-sm btn-info disabled">{{SelectedVariant.InCart}} in cart</button>
<a class="btn btn-default btn-xs" ng-click="pc.MinusItem(product.ProductID, SelectedVariant.VariantID)">
<span class="glyphicon glyphicon-minus"></span>
</a>
</div>
</div>
</div>
</div>
</body>
</html>
Add property float:left to box class. If that doesn't work, please provide a demo.
Jsfiddle: http://jsfiddle.net/z9jbhmd4/
You can add float in your css:
.box {
margin : 5px;
display : inline-block;
width: 170px;
height: 275px;
background-color: #F5FBEF;
text-align:center;
vertical-align: top;
float: left;
}
And to keep the height of the container, move <div class="box">...</div> inside container like <div class="box-container">.....</div>
Then, add css:
.box-container:after {
content: " ";
display: block;
height: 0;
clear: both;
}
I have a bootstrap sidebar that contains a couple buttons. Unfortunately, it looks very ugly and I want each button to be the same size.
These buttons are contained in a sidebar and will be stack vertically. I want to avoid setting a pixel number for each button. Here is the jfiddle
https://jsfiddle.net/66bk2rfc/
HTML
<div id="reading-sidebar" class="col-xs-3 panel-default">
<div id="reading-sidebar-title" class="panel-heading">Options
<button type="button" class="btn btn-xs btn-default pull-right" id="reading-sidebar-hide-btn"><i class="glyphicon glyphicon-remove"></i></button>
</div>
<div id="reading-sidebar-contents" class="panel-body">
<ul class="sidebar-button-list">
<button type="button" id="pre-reading-btn" class="btn btn-default pull-left"><i class="glyphicon glyphicon-minus"></i> Pre Readings</button><br>
<button type="button" id="passage-btn" class="btn btn-default pull-left"><i class="glyphicon glyphicon-minus"></i> Passage</button><br>
<button type="button" id="post-reading-btn" class="btn btn-default pull-left"><i class="glyphicon glyphicon-minus"></i> Post Readings</button><br>
<button type="button" id="media-btn" class="btn btn-default pull-left"><i class="glyphicon glyphicon-minus"></i> Media</button><br>
<button type="button" id="question-btn" class="btn btn-default pull-left"><i class="glyphicon glyphicon-minus"></i> Questions</button>
</ul>
</div>
</div>
The "bootstrap" way to do this would be to use btn-block on your button elements. Like so:
<button type="button" class="btn btn-primary btn-lg btn-block">Full-width Button</button>
You can also just surround them with <div class="btn-group-lg btn-group-vertical">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div id="reading-container" class="col-xs-6">
<div id="reading-sidebar" class="col-xs-3 panel-default"></div>
<div id="reading-sidebar-contents" class="panel-body">
<div class="btn-group-lg btn-group-vertical">
<button type="button" id="pre-reading-btn" class="btn btn-default"><i class="glyphicon glyphicon-minus"></i> Pre Readings</button>
<button type="button" id="passage-btn" class="btn btn-default"><i class="glyphicon glyphicon-minus"></i> Passage</button>
<button type="button" id="post-reading-btn" class="btn btn-default"><i class="glyphicon glyphicon-minus"></i> Post Readings</button>
<button type="button" id="media-btn" class="btn btn-default"><i class="glyphicon glyphicon-minus"></i> Media</button>
<button type="button" id="question-btn" class="btn btn-default"><i class="glyphicon glyphicon-minus"></i> Questions</button>
</div>
</div>
</div>
If I get your question right. Do you mean this:
#reading-sidebar-contents .btn{
width:200px;
}
Here is fiddle: https://jsfiddle.net/66bk2rfc/6/
I changed your fiddle to match a solution. You can give your sidebar a width of 100%. Then you can just make your buttons 80% with one line of css and make them stay in the middle with the margin:0 auto. If you want to adjust your size of the buttons, you can easely change it with just the one line. You could also add the text-align:left, set a font-size for all the buttons,... for better styling to the buttons.
#reading-sidebar
{
width:80%;
margin:0 auto;
}
#reading-sidebar-contents button
{
width:100%;
margin:0 auto;
}
Link: https://jsfiddle.net/66bk2rfc/1/
I suggess You to do it like this:
.btn {
width: 100%;
height: 56px;
padding-left: 2% !important;
}
.btn i {
left: 10px;
width: 10%;
top: 25%;
height: 50%;
}
.btn.pull-left {
text-align: left;
}
Also if you just want only these affect to sidebar buttons, add
#reading-sidebar .btn { } ETC...
If you want it not 100% width and centered, You should do it like this,
.btn { width: 80%; margin-left: 10%; }
That will make it centered easily. :)
I've read the docs on this subject and tried several solutions.
I am looking for a way to align 3 bootstrap buttons in a button group where the first 2 buttons only take the width needed for their content and the last button takes the full width of its parent container.
Plunker: http://plnkr.co/edit/fxpcJE018kW1d72tK9Nn?p=preview
<div class="col-md-12">
<div class="btn-group-justified">
<button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-move"></span>
</button>
<button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-plus"></span>
</button>
<div class="btn btn-default btn-block">Expand this div button to full width</div>
</div>
</div>
Using a little jQuery it is simple to get what you want:
HTML:
<div id="my-row" class="col-md-12 row">
<button type="button" id="btn1" class="btn btn-default">
<span class="glyphicon glyphicon-move"></span>
</button>
<button type="button" id="btn2" class="btn btn-default">
<span class="glyphicon glyphicon-plus"></span>
</button>
<div class="btn btn-default stretch">Expand this div button to full width</div>
CSS:
#my-row{
padding: 0px;
margin: 0px;
}
jQuery:
var width = $('#my-row').width()-($('#btn1').width() + $('#btn2').width()+60);
$( "div.stretch" ).css( "width", width);
$( window ).resize(function() {
var width = $('#my-row').width()-($('#btn1').width() + $('#btn2').width()+60);
$( "div.stretch" ).css( "width", width);
});
JsFiddle:
JsFiddle
This solution can give solution
<div class="row">
<div class="col-md-12">
<div class="btn-group-justified"id="b">
<button type="button" class="btn btn-default"id="a">
<span class="glyphicon glyphicon-move"></span>
</button>
<button type="button" class="btn btn-default"id="aa" >
<span class="glyphicon glyphicon-plus"></span>
</button>
<div class="btn btn-default btn-block"id="aaa">Expand this div button to full width</div>
</div>
</div>
</div>
</body>
css
#aaa{
width:100%;
clear:right;
}
#a{
float:left;
}
#aa{
float:left;
}
jsfiddle