Positioning drop down in panel heading boostrap - html

I'm trying to add drop down to panel header (bootstrap). I've aligned drop down to right but it's not positioning properly.
Code
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-bar-chart-o fa-fw"></i>
Analytics
</h3>
<div class="btn-group" style="float: right;">
<button class="btn">Action</button>
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Item I</li>
<li>Item II</li>
<li>Item III</li>
<li class="divider"></li>
<li>Other</li>
</ul>
</div>
</div>
<div class="panel-body">
<div id="analytics-chart"></div>
</div>
</div>
</div>
</div>

What I would do in this situation is move the btn-group inside of the <h3> tag before applying the float:right; style (either using style="float:right;" or class="pull-right"). Then, simply adjust the top margin to something that makes it fit a little better into the panel-title, such as -8px:
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-bar-chart-o fa-fw"></i>
<div class="btn-group pull-right" style="margin-top:-8px;">
<button class="btn">Action</button>
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li>Item I</li>
<li>Item II</li>
<li>Item III</li>
<li class="divider"></li>
<li>Other</li>
</ul>
</div>
Analytics
</h3>
</div>
<div class="panel-body">
<div id="analytics-chart"></div>
</div>
</div>
</div>
</div>
Also, remember to add dropdown-menu-right to your dropdown when using pull-right, otherwise it will extend beyond the edge of the screen.
Buttons never behave well when added to a panel-heading class, but you're free to tweak the classes to fit your needs.
Hope this helps!
Bootply Example

Related

How to change the direction of drop down child menu for Arabic RTL through custom CSS?

We have a custom eCommerce website and below is the code for the categories list which is a drop-down menu.
<div id="nav-header" class="nav-header navbar-default">
<div class="container ">
<div class="row">
<nav class="ms-mb-0" role="navigation">
<div class="col-sm-3 col-md-3">
<!--navheader sidebar categories on home page-->
<div class=" hover-dropdown dropdown vertical-megamenu navheader-sidebar-category ">
<div class="ms-br-zero dropdown-toggle btn-primary" type="button"
id="dropdownMenu1" data-toggle="dropdown">
<div id="menu-icon">
{{'SHOP BY CATEGORIES'|msTranslate}}
<i class="fa fa-bars pull-right ms-pt-xs"></i>
</div>
</div>
<ul
class="list-group nav-ul-color dropdown-menu ms-br-zero ms-br-none ms-pt-0 ms-pb-0 ms-mt-0 ms-w-full ms-z-index20 ms-pos-absolute"
role="menu" aria-labelledby="dropdownMenu1" aria-expanded="true"
data-ng-init="show={}">
<li class="list-group-item ms-br-zero level1" role="presentation "
data-ng-repeat="category in navigation.header.links">
<a href="{{category.url}}" class="ms-p-0 ms-ws-normal"
title="{{category.title|msTranslate}}">
{{category.title}}
<span data-ng-if="category.children.length ">
<i class="fa fa-angle-right pull-right">
</i>
</span>
</a>
<ul ng-if="category.children.length" class="list-unstyled level2 vertical"
ng-style="{'column-count':{{getcount(category)}}}">
<div class=" ms-p-xs dropdownMenu-lvl2">
<div class="dropdownMenu-lvl3 ms-pr-xs ms-lh-25 ms-mb-s "
ng-repeat="subcategory in category.children">
<a href="{{subcategory.url}}"
title="{{subcategory.title|msTranslate}}">
{{subcategory.title}}
<i ng-if="subcategory.children.length"
class="fa fa-caret-left">
</i>
</a>
<ul class="list-unstyled level3"
ng-if="subcategory.children.length">
<li ng-repeat="subcategory2 in subcategory.children"
class="subcategory2 ">
<a href="{{subcategory2.url}}"
title="{{subcategory2.title}}"
class="level3-links ">
{{subcategory2.title}}
</a>
</li>
</ul>
</div>
</div>
</ul>
</li>
<li class="list-group-item ms-br-zero level1" role="presentation ">
<a href="/allcategories" class="ms-p-0 ms-ws-normal"
title="{{'SEE ALL CATEGORIES'|msTranslate}}">
{{'SEE ALL CATEGORIES'|msTranslate}}
</a>
</li>
</ul>
</div>
</div>
If the language is English, subcategories show on the right side which is perfect as below:
But if the language is Arabic, subcategories show on the right side which is wrong because it is overflowing from the screen:
For Arabic, the menu should show on the left side of the screen.
I tried the following in the custom CSS but still the menu in Arabic doesn't show on the left side:
body .dropdownMenu1.dropdownMenu-lvl2,
body .dropdownMenu-lvl2.dropdownMenu-lvl3 {left:-250px !important;}
How to correct the code so that the menus in Arabic show on the left side.

bootstrap - components resize issues

I'm new to the world of UI design. I'm trying to get a basic page up & running with bootstrap. What I'm after is the underlying reason for using bootstrap which is to scale the page & it's components depending on the device on which the web page is loaded. I'm failing just with this very requirement :)
Here's the code I'm trying to get working
<div class="container-fluid">
<div class="row-fluid ">
<div class="row row-eq-height ">
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 bg-primary pull-left">
<a id="home_btn" href="#"><i class="material-icons col-xs-1 col-sm-1 col-md-1 col-lg-1 " style="padding-top: 12px;font-size:70px;color:lightblue;text-shadow:2px 2px 4px #000000; text-align: left;">home</i></a>
</div>
<div class="col-xs6 col-sm-6 col-md-6 col-lg6 bg-primary">
<div class="page-header text-center" >
<p> <h2>BOOTSTRAP TRIAL </h2> </p>
</div>
</div>
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 text-center bg-success" style="padding-top: 20px;">
<h3> LOGGED IN</h3>
</div>
<div class="col-xs-2 col-sm-2 col-md-2 col-lg- bg-primary text-right pull-right">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="material-icons" style="font-size:70px;color:lightblue;text-shadow:2px 2px 4px #000000;text-align:right;padding-left: 215px; ">account_circle</i>
</a>
<ul class="dropdown-menu">
<li>Account Settings <span class="glyphicon glyphicon-cog pull-right blue"></span></li>
<li class="divider"></li>
<li>User stats <span class="glyphicon glyphicon-stats pull-right blue"></span></li>
<li class="divider"></li>
<li>Messages <span class="badge pull-right blue"> 42 </span></li>
<li class="divider"></li>
<li>Favourites Snippets <span class="glyphicon glyphicon-heart pull-right blue"></span></li>
<li class="divider"></li>
<li>Sign Out <span class="glyphicon glyphicon-log-out pull-right blue"></span></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
This code doesn't re-size all the contents of the web page being loaded. I see just half the contents when I click on "restore" button of the browser.
A few questions
1) My understanding of bootstrap is that it is mobile first technology meaning, if we were to develop for small devices, then it could scale up to anything big. Please correct me if I've misunderstood this. Hence, Does one have to specify, -xs-, -md- & -lg- for all the elements in question to get the re-size working or is specifying -xs- enough? If not, which of these should I specify so that the scaling automatically happens across any device.
2) Is responsive web design only about handling content re-sizing?
I'd highly appreciate any help to get me moving here please.
Can you please check this code
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container-fluid">
<div class="row-fluid">
<div class="row row-eq-height">
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 bg-primary pull-left">
<a id="home_btn" href="#"><i class="material-icons col-xs-1 col-sm-1 col-md-1 col-lg-1" style="padding-top: 12px;font-size:70px;color:lightblue;text-shadow:2px 2px 4px #000000; text-align: left;">home</i></a>
</div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 bg-primary">
<div class="page-header text-center" >
<p> <h2>BOOTSTRAP TRIAL </h2> </p>
</div>
</div>
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 text-center bg-success" style="padding-top: 20px;">
<h3> LOGGED IN</h3>
</div>
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 bg-primary text-right pull-right">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="material-icons" style="font-size:70px;color:lightblue;text-shadow:2px 2px 4px #000000;text-align:right;padding-left: 215px; ">account_circle</i>
</a>
<ul class="dropdown-menu">
<li>Account Settings <span class="glyphicon glyphicon-cog pull-right blue"></span></li>
<li class="divider"></li>
<li>User stats <span class="glyphicon glyphicon-stats pull-right blue"></span></li>
<li class="divider"></li>
<li>Messages <span class="badge pull-right blue"> 42 </span></li>
<li class="divider"></li>
<li>Favourites Snippets <span class="glyphicon glyphicon-heart pull-right blue"></span></li>
<li class="divider"></li>
<li>Sign Out <span class="glyphicon glyphicon-log-out pull-right blue"></span></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>

Bootstrap Centering Content within a Div

Basically I want my drop down boxes to be horizontally aligned in the center of the <div>. Currently they are in a column and inside a <div> which has displayed them vertically, by default and has pushed the content to the left of the <div>.
I'm using the latest version of bootstrap and only have CSS to pad the header and to set it as transparent!
<div class=" navbar transparent navbar-default navbar-fixed-top" role="navigation"> <!--HEADER-->
<div class="container-fluid header"> <!--CONTAINER- Needs to be inset slightly-->
<div class="row">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!--First NavBar Colum - Logo is Located Here-->
<div class=" navbar-collapse collapse">
<div class="col-sm-4 ">
</div>
<!--Second NavBar Colum - Centered Horizontal Navigation Links are Located Here-->
<div class="col-sm-4 ">
<ul class="nav navbar-nav navbar-left">
<ul class="dropdown">
<i class="fa fa-circle-o"></i>
PLAY
<ul class="dropdown-menu">
<li class="divider"></li>
<li>Public Teatimes</li>
<li>Member Teatimes</li>
<li>Course Tour</li>
<li>Rates and Ratings</li>
<li>Outings</li>
</ul>
</ul>
<ul class="dropdown">
<i class="fa fa-circle-o"></i>
CLUB
<ul class="dropdown-menu">
<li class="divider"></li>
<li>Membership</li>
<li>Calender</li>
<li>Lessons and Shop</li>
<li>Bar and Food</li>
</ul>
</ul>
<ul>
<i class="fa fa-circle-o"></i>
CONTACT
</ul>
</ul>
</div>
<!--Third NavBar Colum - Social Media Icons are Located Here-->
<div class="col-sm-4">
<i class="fa fa-facebook-square fa-3x"></i>
<i class="fa fa-twitter-square fa-3x"></i>
<i class="fa fa-instagram fa-3x"></i>
</div>
</div> <!--/ .nav-collapse-->
</div>
</div>
</div>
In .navbar-nav, .navbar-left there is float:left . SO, you have remove that first float:none. Then on parent col-sm-4 you can add .text-center.
Try something like this
.navbar-nav{
width:250px;
margin:0 auto;
float:none;
text-align:center;
}
And remove float from <li> if you use.
#media (min-width: 768px)
.navbar-nav {
text-align: center;}

Bootstrap CSS Alignment

I have been trying to get some alignment to work but I am having a hard time being successful. I'm not sure if there is already a CSS style in bootstrap for vertical alignment or not but that is what I am trying to accomplish.
I have a DIV (.well class) with an image and some text inside it. The Image aligns fine as its responsive so the height and placement is good. However, I am trying to align the button and Text vertically in the middle.
Here is a jsFiddle: http://jsfiddle.net/6z9skpeh/
<div class="col-md-6">
<div class="well wellFriends">
<div class="row">
<div class="col-md-4 friendPic">
<img src="http://oi62.tinypic.com/289j41s.jpg" class="img-responsive">
</div>
<div class="col-md-8 friendDetails">
<div class="row">
<div class="col-md-6"><strong>Bob Smith</strong>
<br><em>Department Name</em>
</div>
<div class="col-md-5 pull-right">
<!-- Single button -->
<div class="btn-group pull-right">
<button type="button" class="btn btn-primary dropdown-toggle pull-right" data-toggle="dropdown" aria-expanded="false">Friends <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li class="divider"></li>
<li>Separated link
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
This is what I have so far:
This is what I am trying to do:
You can try like this: demo
css:
.v_align {
font-size: 0;
}
.v_align >[class*="col"] {
float: none;
font-size: 14px;
display: inline-block;
vertical-align: middle;
}
HTML:
<div class="row v_align">..</div>

Bootstrap buttons group not displayed properly in footer of a panel

I am using Bootstrap and can't find my problem where button groups in not aligned properly when inserten in right hand side of the panel footer.
My code id:
<div class="container">
<div class="col-md-6">
<div class="panel panel-primary">
<div class="panel-heading"><b>My Title</b><span class="pull-right">123</span></div>
<div class="panel-body">
Just a test text<br>
</div>
<div class="panel-footer">
Some information herre
<div class="btn-group pull-right">
<button type="button" class="btn btn-primary dropdown-toggle " data-toggle="dropdown">
Group of buttons <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><span class="glyphicon glyphicon-edit"></span> Edit </li>
<li><span class="glyphicon glyphicon-trash"></span> Delete</li>
<li class="divider"></li>
<li><span class="glyphicon glyphicon-list-alt"></span> PDF</li>
</ul>
</div>
</div>
</div>
</div>
</div><!-- /.container -->
To demonstrate a problem please take a look at working code:
http://jsfiddle.net/69r7s63w/
Actually the easiest and cleanest way is to add a clearfix class to your footer:
<div class="panel-footer clearfix">
Demo: http://jsfiddle.net/r819f85u/
You don't need to add any extra markup to archive this. If you have multiple instances like this, you can even override panel-footer to let take effect automatically, but you'd better use Less/Sass/... version, otherwise will be complicated to add an clearfix effect.
Below is an example by using Sass:
// Overriding must be written or imported after Bootstrap
.panel-footer {
#include clearfix;
}
If you use containers it will fit better within the footer.
<div class="row">
<div class="col-xs-6">
<p>
Some information herre
</p>
</div>
<div class="col-xs-6">
<!-- Single button -->
<div class="btn-group pull-right">
<button type="button" class="btn btn-primary dropdown-toggle " data-toggle="dropdown">Group of buttons <span class="caret"></span></button>
<ul class="dropdown-menu" role="menu">
<li><span class="glyphicon glyphicon-edit"></span> Edit </li>
<li><span class="glyphicon glyphicon-trash"></span> Delete</li>
<li class="divider"></li>
<li><span class="glyphicon glyphicon-list-alt"></span> PDF</li>
</ul>
</div>
</div>
</div>
Updated fiddle
You can also change the size of the button to btn-sm or btn-xs. Also I'm not entirely sure why but making the button float right causes it to not be able to stretch heights within a container, usually I see
<div class="clearfix"></div>
put at the end of float elements which will stretch the container.
You need to adjust line height of text Some information here, since it is not wrapped under any div or so..
Just change
Some information here to <span class="footer-text">Some information here</span> and then adjust the line height of .footer-text class using following CSS
.footer-text{
line-height:33px;
}
Fiddle here : http://jsfiddle.net/rahulrulez/69r7s63w/1/
Updated Solution with best practices
Change HTML to this :
<div class="container">
<div class="col-xs-6 footer-text">Some information herre</div>
<!-- Single button -->
<div class="col-xs-6 pull-right">
<button type="button" class="btn btn-primary dropdown-toggle " data-toggle="dropdown">
Group of buttons <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><span class="glyphicon glyphicon-edit"></span> Edit </li>
<li><span class="glyphicon glyphicon-trash"></span> Delete</li>
<li class="divider"></li>
<li><span class="glyphicon glyphicon-list-alt"></span> PDF</li>
</ul>
</div>
</div>
http://jsfiddle.net/rahulrulez/69r7s63w/3/