Update: Using flexbox is an option, but a solution that supports legacy browsers would be preferred.
It should be an easy task, but now I am searching for hours for an solution without success. I would like to create an navigation where the middle span "Very long headline 1 2 2 3 4 ..." does not do a line break and grow vertically when the view port size is getting very small. Content that does not fit into the span header-title should be hidden.
For a better understanding I attached two graphics and a jsfiddle example.
Current:
Target:
jsfiddle:
https://jsfiddle.net/herbert_hinterberger/ofu8c8rn/3/
<div class="container-fluid">
<div class="row row-offcanvas row-offcanvas-left">
<div class="col-xs-12 col-sm-9">
<div class="row" id="header"> <!--header-->
<div class="col-xs-12">
<span id="header-menu-trigger" class="pull-left hidden-md hidden-lg" data-toggle="offcanvas">
<i class="fa fa-bars fa-3x"></i>
</span>
<span>
<h3 id="header-title">Very long headline 1 2 3 4 5 6 7 8 9 10 </h3>
</span>
<span class="notification-container pull-right">
<h3 class="notification">8</h3>
</span>
</div>
</div> <!--/header-->
</div> <!--/offcanvase-->
</div> <!--/row-->
Try flex. Flex will ensure that the middle element stretches/shrinks to the available space. Also, remove pull-right on the notification-container div.
https://jsfiddle.net/5s3v55px/
Add this CSS
.my-flex{
display:flex;
}
.flex-1{
flex:1;
}
HTML Changes
<div class="col-xs-12 my-flex">
<span id="header-menu-trigger" class="pull-left hidden-md hidden-lg" data-toggle="offcanvas">
<i class="fa fa-bars fa-3x"></i>
</span>
<span class="flex-1">
<h3 id="header-title">Very long headline 1 2 3 4 5 6 7 8 9 10 </h3>
</span>
<span class="notification-container">
<h3 class="notification">8</h3>
</span>
</div>
Related
I have the following container with 3 columns using Bootstrap 4
<section id="features">
<div class="container-fluid">
<div class="row justify-content-around">
<div class="col-lg-4 col-md-12 ">
<i class="fas fa-check-circle"></i>
<h3>Easy to use.</h3>
<p>So easy to use, even your dog could do it.</p>
</div>
<div class="col-lg-4 col-md-12" >
<i class="fas fa-bullseye"></i>
<h3>Elite Clientele</h3>
<p>We have all the dogs, the greatest dogs.</p>
</div>
<div class="col-lg-4 col-md-12">
<i class="fas fa-heart"></i>
<h3>Guaranteed to work.</h3>
<p>Find the love of your dog's life or your money back.</p>
</div>
</div>
</div>
</section>
I want to add space between them so they are more separated, however when i try to add padding or margin it breaks the row. How can i add the space maitaining the three items in the same row.
Paddings inside cols works fine. Use class px-5. You can use number form 0 to 5 in it. px means "padding x" (both left and right). Although you can use size breakpoints in it, like px-sm-3. More about padding in Bootstrap 4 here https://getbootstrap.com/docs/4.4/utilities/spacing/
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<section id="features">
<div class="container-fluid">
<div class="row justify-content-around">
<div class="col-lg-4 col-sm-12 px-5">
<i class="fas fa-check-circle"></i>
<h3>Easy to use.</h3>
<p>So easy to use, even your dog could do it.</p>
</div>
<div class="col-lg-4 col-sm-12 px-5" >
<i class="fas fa-bullseye"></i>
<h3>Elite Clientele</h3>
<p>We have all the dogs, the greatest dogs.</p>
</div>
<div class="col-lg-4 col-sm-12 px-5">
<i class="fas fa-heart"></i>
<h3>Guaranteed to work.</h3>
<p>Find the love of your dog's life or your money back.</p>
</div>
</div>
</div>
</section>
I advice to use Flex to manage rows (and columns) of stuffs: it also provides methods to define inner and outer space of elements.
<div class="card-body" style="opacity:0.99;"> <!-- stacking context’s root element [![enter image description here][1]][1]-->
<h5 style="padding-left:60px;position:relative;z-index:10;" class="card-title"><!-- stacking order: 1 -->
<i style="position:absolute;font-size:60px;color:red;top:-10px;left:-10px;" class="fa fa-play-circle-o" aria-hidden="true"></i> Video Title
</h5>
<div class="card-details-1 clearfix" style="position:relative;z-index:20;"><!-- stacking order: 2 -->
<div>
<span class="card-date float-left">19.02.17</span>
<a class="card-username float-right" href="#">Username</a>
</div>
</div>
<div class="card-details-2 clearfix">
<div>
<span class="card-duration float-left">7:56 min</span>
<span class="card-votes float-right">20 Votes</span>
</div>
</div>
<a class="card-btn" href="#">View Video</a>
</div>
I have applied an opacity value less than 1 to the div.card-body in order to form a new stacking context.
h5 and div.card-details-1 are positioned and have a z-index value.
Why I can't get the black-colored effect shown in the picture?
There are so many questions on this, but they all seem to just want one item on the left and one on the right, or a button group. All of those are straightforward.
How can I achieve similar to this bootply
but instead of two buttons in the group on the right, two other elements - two divs, or two h3 for example?
Whatever I try these 2 elements always end up vertically stacked and not horizontally aligned in the right side of the footer.
EDIT
#Harinder88 provided this solution which, as you can see, does do what I asked and so I have accepted as the answer as I think in the vast majority of use cases, this is what most people are trying to achieve.
However, you can see that if the text is too long for the column, it gets wrapped and now everything is not on a single line. But I accept that is the compromise of having a responsive design. It just so happens that in my actual use case, that last item cannot be allowed to wrap, so I just have to give it a fixed width to solve that. Thanks #Harinder88.
Now see this example i aligned 2 items horizontal in left and right with 2 methods u can use any 1 of them
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">
<ul class="list-inline">
<li class="col-xs-12">
<div class="pull-right">
<div class="row">
<div class="col-md-6 col-xs-6">
<p>Left side with col</p>
</div>
<div class="col-md-6 col-xs-6">
<p> Right side with col</p>
</div>
</div>
</div>
<div class="pull-left">
<div class="pull-left">Left side with pull</div>
<div class="pull-right">Right side with pull</div>
</div>
</li>
</ul>
</div>
</div>
<div class="panel-body">Content here..</div>
</div>
<hr>
you can use pull-right for align div right and pull-left for align div on left side .
if you want to do further partition you can use use same things again.
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">
<ul class="list-inline">
<li class="col-xs-12">
<div class="pull-right">
<button class="btn btn-default">ON</button>
<button class="btn btn-primary active">OFF</button>
</div>
<div class="pull-left">
<h4>
Fotter (you can use anything here button code or link tag , you can remove hr tag and use anything you want )
</h4>
</div>
</li>
</ul>
</div>
</div>
<div class="panel-body">Content here..</div>
</div>
I managed to figure this out by replacing the button groups and the buttons with spans, then it works fine. Everything aligned on one line, 1 item pulled left and 2 pulled right.
<div class="panel-footer">
<div class="panel-title">
<ul class="list-inline">
<li class="col-xs-12">
<span class="pull-right">
<span>Recording - Last updated at x</span>
<span class="trail-status">PUBLISHED</span>
</span>
<h5>x comments
</h5>
</li>
</ul>
</div>
<div class="clearfix">
</div>
</div>
I have an app that I'm building with Bootstrap 4. I need to center some icons underneath an image. I have a Bootply here. My code looks like this:
<div class="container">
<br>
<div class="row">
<div class="col-lg-6">
<div class="row">
<div class="col-md-3">
<img alt="Picture" src="http://cdn.bgr.com/2015/11/bill-gates.jpg" class="img-circle center-block" style="max-height:6.0rem;">
<br>
<ul class="list-inline">
<li class="list-inline-item"><i class="fa fa-twitter"></i></li>
<li class="list-inline-item"><i class="fa fa-google-plus"></i></li>
<li class="list-inline-item"><i class="fa fa-linkedin"></i></li>
</ul>
</div>
<div class="col-md-9">
<div><strong>Bill Gates</strong></div>
<p>
Here is some information about Bill Gates.
</p>
</div>
</div>
</div>
</div>
</div>
My question is, how do I horizontally center the three icons underneath my image so that it looks like a centered toolbar?
On your UL tag, remove the inline-list class, it's enforcing a float.
I'm trying to render a list of items with Bootstrap. Each item will show an icon, some left-aligned content and some right-aligned content. It will look something like this:
+----------------------------------------------------------+
| Peyton Manning Denver |
| [vertically QB Broncos |
| centered icon] #18 |
| Tenesee |
+----------------------------------------------------------+
| Andrew Luck Indianapolis |
| [vertically QB Colts |
| centered icon] #7 |
| Stanford |
+----------------------------------------------------------+
In an attempt to do this, I was using a ul list-inline. The reason why is because the icon will be smaller. It won't take up a full bootstrap column. However, if I use the list-inline, I don't know how to make the other columns take up the remaining space. I was trying this:
<div class="row">
<div class="col-xs-12 col-sm-12 col-lg-12">
<ul class="list-inline">
<li>
<i class="glyphicon glyphicon-tree-conifer" style="font-size:2.2rem; top:-10px;"></i>
</li>
<li>
<h4 style="margin-top:4px;">Peyton Manning</h4>
<div class="row">
<div class="col-xs-8">
<h5>QB</h5>
<h5>#18</h5>
<h5>Tennessee</h5>
</div>
<div class="col-xs-4 pull-right">
<h5>Denver</h5>
<h5>Broncos</h5>
</div>
</div>
</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-lg-12">
<ul class="list-inline">
<li>
<i class="glyphicon glyphicon-tree-conifer" style="font-size:2.2rem; top:-10px;"></i>
</li>
<li>
<h4 style="margin-top:4px;">Andrew Luck</h4>
<div class="row">
<div class="col-xs-8">
<h5>QB</h5>
<h5>#7</h5>
<h5>Stanford</h5>
</div>
<div class="col-xs-4 pull-right">
<h5>Indianapolis</h5>
<h5>Colts</h5>
</div>
</div>
</li>
</ul>
</div>
</div>
I'm not sure how to include the icon and then grab the rest of the space such that I can left-align and right-align content in that space. Can someone please steer me in the right direction?
Thank!
In Bootstrap 3 there are the pull-left and pull-right classes that float left and right respectively.
You can use those and the grid system of Bootstrap and with less markup achieve the desired result.
HTML:
<div class="container-fluid">
<div class="row">
<div class="col-xs-1 text-center">
<i class="glyphicon glyphicon-tree-conifer product-icon"></i>
</div>
<div class="col-xs-5">
<div class="pull-left">
<h5>QB</h5>
<h5>#18</h5>
<h5>Tennessee</h5>
</div>
</div>
<div class="col-xs-6">
<div class="pull-right">
<h5>Denver</h5>
<h5>Broncos</h5>
</div>
</div>
</div>
</div>
CSS:
.product-icon { font-size:2.2rem; margin-top:20px;}
Here is a jsfiddle with a demo. I used only the col-xs-* but only to keep it simple.
Edit: To center the icon you can use the text-center class, also provided by Bootstrap. To vertically align the icon with CSS is not easily achievable since your main concern is that the div.row does not have a fixed height. So I gave it a small margin-top instead.