Bootstrap columns inside column placement issue - html

I am working on a site, of which has to have a description section. I am trying to achieve this by having two Bootstrap columns, one sized 8 and then another sized 4 to make sure it is equal to 12. Then in the column which is 8, I want to have two columns inside, to achieve one column of text on the left and then a second column of text on the right.
There is just a problem, as it doesn't seem to be working and whenever I try to do this, it just creates a second column underneath the first one inside of the 8 column.
I have attached an image to make it easier to see what I got and what I am trying to achieve. Any help is much appreciated.
Image of current situation:
What I am trying to achieve:
.partLineDesc{
margin-top: 30px;
text-align: center;
}
.leftContDesc{
margin-top: 20px;
background-color:grey;
}
.rightContDesc{
background-color:grey;
margin-top: 20px;
}
.cottonImg{
margin-top: 15px;
text-align: left;
}
.partLineDesc2{
margin-top: 20px;
text-align: center;
}
.securInfo{
margin-top: 30px;
text-align: center;
background-color:#eff4f9;
border-radius: 10px;
border: 2px solid #dddddd;
padding: 20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-md-8">
<div class="partLineDesc">
<img src="partDesc.png" alt="line seperation" class="img-responsive" style="width:1000px; height:5px;">
</div>
<div class="leftContDesc">
<div clas="col-md-6">
<p>text text text text text text text text text text text text
<br>text text text text text text text text text text text text
</p>
<img src="cottonImg.png" alt="100% Cotton" class="img-responsive" style="width:100px; height:100px;">
</div>
</div>
<div class="rightContDesc">
<div clas="col-md-6">
<p>text text text text text text text text text text text text
<br>text text text text text text text text text text text text
</p>
</div>
</div>
<div class="partLineDesc2">
<img src="partDesc.png" alt="line seperation" class="img-responsive" style="width:1000px; height:5px;">
</div>
</div>
<div class="col-md-4">
<div class="securInfo">
</div>
</div>
</div>

Your left and right DIV's wrap the Bootstrap col-md-6 columns so they no longer float next to each other. Also, always put nested col-*s inside another row so the padding is correct..
<div class="container-fluid">
<div class="row">
<div class="col-md-8">
<div class="partLineDesc">
<img />
</div>
<div class="row">
<div class="col-md-6">
<div class="leftContDesc">
<img />
</div>
</div>
<div class="col-md-6">
<div class="leftContDesc">
<p>
</p>
</div>
</div>
</div>
<div class="partLineDesc2">
<img/>
</div>
</div>
<div class="col-md-4">
<div class="securInfo">
</div>
</div>
</div>
</div>
Demo: http://codeply.com/go/yRQum3xKKY

It seems your bootstrap columns are all over the place.
You really need to wrap everything you're trying to split into columns into an overhead div that way you're saying that your main container is taking up 12 columns of that grid then you decide which of those 12 the inside columns need to take up.
Quick mock-up below.
---
.partLineDesc{
margin-top: 30px;
text-align: center;
}
.leftContDesc{
margin-top: 20px;
background-color:grey;
}
.rightContDesc{
background-color:grey;
margin-top: 20px;
}
.cottonImg{
margin-top: 15px;
text-align: left;
}
.partLineDesc2{
margin-top: 20px;
text-align: center;
}
.securInfo{
margin-top: 30px;
text-align: center;
background-color:#eff4f9;
border-radius: 10px;
border: 2px solid #dddddd;
padding: 20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-sm-8">
<div class="partLineDesc">
<img src="partDesc.png" alt="line seperation" class="img-responsive" style="width:1000px; height:5px;">
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-12">
<div class="leftContDesc col-sm-4 col-md-4 col-lg-4">
<p>
text text text text text texttext text text text text text
<br> text text text text text texttext text text text text text
</p>
<img src="cottonImg.png" alt="100% Cotton" class="img-responsive" style="width:100px; height:100px;">
</div>
<div class="rightContDesc col-sm-4 col-md-4 col-lg-4">
<p>
text text text text text texttext text text text text text
<br> text text text text text texttext text text text text text
</p>
</div>
<div class="col-sm-4 col-md-4 col-lg-4">
<div class="securInfo">
</div>
</div>
</div>
<div class="partLineDesc2">
<img src="partDesc.png" alt="line seperation" class="img-responsive" style="width:1000px; height:5px;">
</div>
</div>

Related

Div bootstrap background position

issue
I am having issues with this layout. I want to position a picture of an app right in the center of these boxes. it is important that the image is visible over the top and under the bottom of background for the sections with text. I have tried everything both as background and as normal image (position, z-index, etc.).
I am using bootstrap for col and row. I also needs this to look beautiful on mobile. I need design to look at attached picture, but with the picture in the middle in front of the background. Any suggestions?
Current code and CSS:
<center>
<div class="margin50">
<section class="appfeatures section-spacing">
<div class="container_appfeatures">
<div class="row">
<div class="col-md-3 text-right"><h3 class="white">Headline</h3><br />text text text text text text text text text text text text text text text text text text </div>
<div class="col-md-1 text-left"><img class="appicon_white" src="img/createtip_white.png" alt="Opret Tip Ikon"></div>
<div class="col-md-offset-4 col-md-1 text-right"><img class="appicon_white" src="img/rank_white.png" alt="Rank List Ikon"></div>
<div class="col-md-3 text-left"><h3 class="white">Headline</h3><br />text text text text text text text text text text text text text text text text text text </div>
<div class="col-md-3 text-right"><h3 class="white">Headline</h3><br />text text text text text text text text text text text text text text text text text text </div>
<div class="col-md-1 text-left"><img class="appicon_white" src="img/feed_white.png" alt="Live Score Ikon"></div>
<div class="col-md-offset-4 col-md-1 text-right"><img class="appicon_white" src="img/profile_white.png" alt="Eksperter Ikon"></div>
<div class="col-md-3 text-left"><h3 class="white">Headline</h3><br />text text text text text text text text text text text text text text text text text text </div>
</div>
</div>
</section>
</div>
</center>
.appicon_white {
width: 60px;
height: 60px;
}
.appfeatures {
background: rgb(102,204,153);
background: linear-gradient(180deg, rgba(102,204,153,1) 0%, rgba(30,130,76,1) 100%);
opacity: 0.5;
}
.container_appfeatures {
width: 80%;
}
.margin50 {
margin-top: 75px;
margin-bottom: 75px;
width:100%;
height:100%;
background-image: url("../img/profile.png");
background-repeat: no-repeat;
background-position: center center;
padding-top:95px;
padding-bottom:95px;
}
Don't use col-md-offset-4 just col-md-4 and your must use <div class="row"> in every row. Here I updated your html code:
<center>
<div class="margin50">
<section class="appfeatures section-spacing">
<div class="container_appfeatures">
<div class="row">
<div class="col-md-3 col-sm-3 text-right">
<h3 class="white">Headline</h3>
<br />text text text text text text text text text text text text text text text text text text
</div>
<div class="col-md-1 col-sm-1 text-center">
<img class="appicon_white" src="img/createtip_white.png" alt="Opret Tip Ikon">
</div>
<div class="col-md-4"> </div>
<div class="col-md-1 col-sm-1 text-center">
<img class="appicon_white" src="img/rank_white.png" alt="Rank List Ikon">
</div>
<div class="col-md-3 col-sm-3 text-left">
<h3 class="white">Headline</h3>
<br />text text text text text text text text text text text text text text text text text text
</div>
</div>
<img src="https://path to your iphone image">
<div class="row">
<div class="col-md-3 col-sm-3 text-right">
<h3 class="white">Headline</h3>
<br />text text text text text text text text text text text text text text text text text text
</div>
<div class="col-md-1 col-sm-1 text-center">
<img class="appicon_white" src="img/feed_white.png" alt="Live Score Ikon">
</div>
<div class="col-md-4"> </div>
<div class="col-md-1 col-sm-1 text-center">
<img class="appicon_white" src="img/profile_white.png" alt="Eksperter Ikon">
</div>
<div class="col-md-3 col-sm-3 text-left">
<h3 class="white">Headline</h3>
<br />text text text text text text text text text text text text text text text text text text
</div>
</div>
</div>
</section>
</div>
</center>
CSS code updated:
.appicon_white {
width: 40px;
height: 40px;
}
.appfeatures {
background: rgb(102, 204, 153);
background: linear-gradient(180deg, rgba(102, 204, 153, 1) 0%, rgba(30, 130, 76, 1) 100%);
opacity: 0.5;
margin: 170px 0;
position: relative;
}
.container_appfeatures {
width: 80%;
margin: 75px auto;
}
.margin50 {
width: 100%;
position: absolute;
z-index: 5;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
}
.margin50 img {
max-width: 250px;
width: 100%;
}
img.phone-middle {
position: absolute;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
}
Jsfiddle: https://jsfiddle.net/marksalvania/94uyLvp1/
then on your mobile/smaller view just add this on your media queries something like this:
.col-md-3 {
text-align:left;
font-size: 10px; /*just adjust this to your desired size*/
}
.col-md-1,
.margin50 {
display:none; /*this is just optional if you just want hide icons on mobile view. Much better if you will hide the phone image on mobile view for sleek and clean layout.*/
}
.your-other-styles {
/*add your other styles here*/
}

Bootstrap CSS button fixed position after text

I am trying to set cards with information in columns. As the texts displayed have different lenghts, I want to fixed the possition of the Learn More button related to the end of the card, so no matter what comes before, the buttons are always aligned.
Furthermore, I want to separate the cards between rows, but I haven't been able to find a solution yet, because if I change margins it only applies in the last row.
Here is my code:
<div class="row my-flex-card">
<div class= "col-xs-4 col-sm-4 col-md-4 col-lg-4" ng-repeat="woman in women">
<!--Card-->
<div class="card">
<!--Card image-->
<img class="img-fluid" ng-src="{{woman.image_url}}" alt="{{woman.name}}">
<!--Card content-->
<div class="card-body inline-block">
<!--Title-->
<h4 class="card-title">{{woman.name}}</h4>
<!--Text-->
<p class="card-text"> <h5>{{woman.field}}</h5> <br> {{woman.job}}</p>
<a class="btn btn-success" href="#!/women/details/{{woman._id}}">Learn more</a>
</div>
</div>
<!--/.Card-->
</div>
</div>
My CSS:
.my-flex-card > div > div.card {
height: calc(100% - 15px);
margin-bottom: 15px;
}
.row {
margin-bottom: 50px;
}
That .row feature isn't working.
This is how my website looks like right now:
Thank you :)
.parent {
display: flex;
flex-direction: row;
padding: 10px;
}
.parent .child {
padding-right: 10px;
flex-grow: 1;
width: 33%;
position:relative;
}
.parent .child .content {
height: 100%;
box-shadow: 0 0 1em gray;
}
.content img{
background-size:cover;
width:100%;
}
.content h3,p{
padding:10px;
}
.content input{
position:absolute;
bottom:5px;
margin-left: 35%;
margin-top:10px;
}
<div class="parent">
<div class="child">
<div class="content">
<div>
<img src="https://www.w3schools.com/html/pic_mountain.jpg"/>
<h3> test 3</h3>
<p>text text text text text text text text text text text text text text text text text text text</p>
</div>
<div><input type="button" value="click" /></div>
</div>
</div>
<div class="child">
<div class="content">
<div>
<img src="https://www.w3schools.com/html/pic_mountain.jpg"/>
<h3> test 2</h3>
<p>text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text tex </p>
</div>
<div><input type="button" value="click" /></div>
</div>
</div>
<div class="child">
<div class="content">
<div>
<img src="https://www.w3schools.com/html/pic_mountain.jpg"/>
<h3> test 1</h3>
<p>text text text text text text text text text text text text tex</p>
</div>
<div><input type="button" value="click" /></div>
</div>
</div>
</div>
make the box class with position relative :
.boxClassName{
position:relative
}
then make the button class with the following :
.buttonClassName{
position:absolute;
bottom:0;
}

corner image, footer. bootstrap

I need some help. I need to make adaptive image in footer and to put the picture in right corner. Size of pic is: 150x150 px.
<footer>
<div class="container">
<p class="text-xs-center"> TEXT TEXT TEXT<br>
text text text<br>
<a href="</a> </p>
</div>
</footer>
footer {
position: absolute;
width: 100%;
height: 150px;
background-color: rgb(50, 50, 50);
}
I ask you to help me, with some code. With my old code - was bad responsive.On gadgets with 600 x 1024 display - footer text is superimposed on the image.
I don't actually know the if "text-right" is a really bootstrap class... However, I think that this layout would work.
footer {
width: 100%;
height: 150px;
}
<footer>
<div class="container">
<p class="text-xs-center"> TEXT TEXT TEXT<br>
text text text<br>
</p>
<p class="text-right"><img scr="YOUR IMAGE PATH HERE" /></p>
</div>
</footer>
Class "pull-right" should be mentioned in img tag. Further, bootstrap col classes can be used to place text and image side by side.
The code is below:
HTML
footer {
width: 100%;
height: 150px;
background-color: rgb(50, 50, 50);
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<footer>
<div class="container ">
<div class="col-sm-6 col-md-6 col-xs-6">
<p class="text-xs-center text-danger"> TEXT TEXT TEXT<br> text text text<br>
Link
</p>
</div>
<div class="col-sm-6 col-md-6 col-xs-6">
<img src="http://www.fillmurray.com/150/150" alt="image" class="pull-right" /></div>
</div>
</footer>

Bootstrap - Center img in row vertically

I've been trying forever to center this image properly in the row containing the div the img is in. Here's my html
<div class="row">
<div class="col-md-9">
<div class="col-md-12">
<h3 style="text-transform: uppercase"><strong>Title</strong></h3>
<p>Text</p>
<br>
<h3 style="text-transform: uppercase"><strong>Title</strong></h3>
<p>Text</p>
<br>
<h3 style="text-transform: uppercase"><strong>Title</strong></h3>
<p>Text(2 male, 1 female, 3 mixed characters)</p>
</div>
</div>
<div class="col-md-2">
<img class="img-full center-block" src="img/img.jpg" alt="">
</div>
</div>
I've tried all the suggestions on this page and none of them seem to work. https://css-tricks.com/centering-css-complete-guide/
I do not know the height of the element since this is a responsive website, so I tried using translate to move the image, and this happened.
If I use flexbox, then my mobile design breaks because the columns don't collapse right, like this.
If I use this code
.vcenter {
display: inline-block;
vertical-align: middle;
float: none;
}
Nothing happens
So I feel like I've exhausted any well known solutions. Anyone have any idea how to fix this? I have a feeling my issue is linked to my stacking columns within columns, but if I don't do that it breaks my design too...
Edit: This is how I want it to look
At this point you won't be able to vertically align the image because the containing col-md-2 will shrink down to the height of the image. You'll need to ensure that the parent element of the image has larger height value. You can set it to the height of the col-md-9 statically in your css (like I have done in the snippet) or have it check dynamically by javascript. Then you can run the code I have below (the css will work IE 9 and up, I also changed bootstrap class to xs to illustrate in the snippet):
.vcenter {
position: relative;
top: 50%;
transform: translateY(-50%);
}
.taller{ height:300px;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-9">
<div class="row">
<div class="col-md-12">
<h3 style="text-transform: uppercase"><strong>Title</strong></h3>
<p>Text</p>
<br>
<h3 style="text-transform: uppercase"><strong>Title</strong></h3>
<p>Text</p>
<br>
<h3 style="text-transform: uppercase"><strong>Title</strong></h3>
<p>Text(2 male, 1 female, 3 mixed characters)</p>
</div>
</div>
</div>
<div class="col-xs-2 taller">
<img class="img-full center-block vcenter" src="img/img.jpg" alt="">
</div>
</div>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
This should do it for the JAVASCRIPT version
$(document).ready(function(){
matchColHeight();
});
$(window).resize(function(){
matchColHeight();
});
function matchColHeight() {
var col1_height = $('.col1').height();
$('.col2').css('height', col1_height);
}
.vcenter {
position: relative;
top: 50%;
transform: translateY(-50%);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-9">
<div class="row">
<div class="col-md-12 col1">
<h3 style="text-transform: uppercase"><strong>Title</strong></h3>
<p>Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text </p>
<br>
<h3 style="text-transform: uppercase"><strong>Title</strong></h3>
<p>Text</p>
<br>
<h3 style="text-transform: uppercase"><strong>Title</strong></h3>
<p>Text(2 male, 1 female, 3 mixed characters)</p>
</div>
</div>
</div>
<div class="col-xs-2 col2">
<img class="img-full center-block vcenter" src="img/img.jpg" alt="">
</div>
</div>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

vertical divider between two columns in bootstrap

I am using twitter bootstrap, and have a row which has two columns (span6). How do I create a vertical divider between both the spans.
Thanks,
Murtaza
If your code looks like this:
<div class="row">
<div class="span6">
</div>
<div class="span6">
</div>
</div>
Then I'd assume you're using additional DIVS within the "span6" DIVS for holding/styling your content? So...
<div class="row">
<div class="span6">
<div class="mycontent-left">
</div>
</div>
<div class="span6">
<div class="mycontent-right">
</div>
</div>
</div>
So you could simply add some CSS to the "mycontent-left" class to create your divider.
.mycontent-left {
border-right: 1px dashed #333;
}
In Bootstrap 4 there is the utility class border-right which you can use.
So for example you can do:
<div class="row">
<div class="col-6 border-right"></div>
<div class="col-6"></div>
</div>
.row.vertical-divider {
overflow: hidden;
}
.row.vertical-divider > div[class^="col-"] {
text-align: center;
padding-bottom: 100px;
margin-bottom: -100px;
border-left: 3px solid #F2F7F9;
border-right: 3px solid #F2F7F9;
}
.row.vertical-divider div[class^="col-"]:first-child {
border-left: none;
}
.row.vertical-divider div[class^="col-"]:last-child {
border-right: none;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="row vertical-divider" style="margin-top: 30px">
<div class="col-xs-6">Hi there</div>
<div class="col-xs-6">Hi world<br/>hi world</div>
</div>
Well here's another option which I've been using for some time now. It works great for me since I mostly need it do visually separate 2 cols. And it's also responsive. Which means that if I have columns next to each other in medium and large screen sizes, then I would use the class col-md-border, which would hide the separator on smaller screen sizes.
css:
#media (min-width: 992px) {
.col-md-border:not(:last-child) {
border-right: 1px solid #d7d7d7;
}
.col-md-border + .col-md-border {
border-left: 1px solid #d7d7d7;
margin-left: -1px;
}
}
In scss you can generate all needed classes probably from this:
scss:
#media(min-width: $screen-md-min) {
.col-md-border {
&:not(:last-child) {
border-right: 1px solid #d7d7d7;
}
& + .col-md-border {
border-left: 1px solid #d7d7d7;
margin-left: -1px;
}
}
}
HTML:
<div class="row">
<div class="col-md-6 col-md-border"></div>
<div class="col-md-6 col-md-border"></div>
</div>
How it works:
The cols must be inside an element where there are no other cols otherwise the selectors might not work as expected.
.col-md-border:not(:last-child) matches all but the last element before .row close and adds right border to it.
.col-md-border + .col-md-border matches the second div with the same class if these two are next to each other and adds left border and -1px negative margin. Negative margin is why it doesn't matter anymore which column has greater height and the separator will be 1px the same height as the highest column.
It does also have some problems...
When you try to be clever/lazy and use col-XX-X class together with hidden-XX/visible-XX classes inside the same row element.
When you have a lot of columns and need a pixel perfect thing. Since it moves n-1 column 1px to the left.
... But on the other hand it's responsive, works great for simple html and it's easy to create these classes for all bootstrap screen sizes.
To fix the ugly look of a divider being too short when the content of one column is taller, add borders to all columns. Give every other column a negative margin to compensate for position differences.
For example, my three column classes:
.border-right {
border-right: 1px solid #ddd;
}
.borders {
border-left: 1px solid #ddd;
border-right: 1px solid #ddd;
margin: -1px;
}
.border-left {
border-left: 1px solid #ddd;
}
And the HTML:
<div class="col-sm-4 border-right">First</div>
<div class="col-sm-4 borders">Second</div>
<div class="col-sm-4 border-left">Third</div>
Make sure you use #ddd if you want the same color as Bootstrap's horizontal dividers.
If you want a vertical divider between 2 columns, all you need is add
class="col-6 border-left"
to one of your column div-s
BUT
In the world of responsive design, you may need to make it disappear sometimes.
The solution is disappearing <hr> + disappearing <div> + margin-left: -1px;
<div class="container">
<div class="row">
<div class="col-md-7">
1 of 2
</div>
<div class="border-left d-sm-none d-md-block" style="width: 0px;"></div>
<div class="col-md-5" style="margin-left: -1px;">
<hr class="d-sm-block d-md-none">
2 of 2
</div>
</div>
</div>
https://jsfiddle.net/8z1pag7s/
tested on Bootstrap 4.1
With Bootstrap 4 you can use borders, avoiding writing other CSS.
border-left
And if you want space between content and border you can use padding. (in this example padding left 4px)
pl-4
Example:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="offset-6 border-left pl-4">First</div>
<div class="offset-6 border-left pl-4">Second</div>
</div>
If you are still seeking for the best solution in 2018, I found the way this works perfectly if you have at least one free pseudo element( ::after or ::before ).
You just have to add class to your row like this: <div class="row vertical-divider ">
And add this to your CSS:
.row.vertical-divider [class*='col-']:not(:last-child)::after {
background: #e0e0e0;
width: 1px;
content: "";
display:block;
position: absolute;
top:0;
bottom: 0;
right: 0;
min-height: 70px;
}
Any row with this class will now have vertical divider between all of the columns it contains...
You can see how this works in this example.
I have tested it. It works fine.
.row.vdivide [class*='col-']:not(:last-child):after {
background: #e0e0e0;
width: 1px;
content: "";
display:block;
position: absolute;
top:0;
bottom: 0;
right: 0;
min-height: 70px;
}
<div class="container">
<div class="row vdivide">
<div class="col-sm-3 text-center"><h1>One</h1></div>
<div class="col-sm-3 text-center"><h1>Two</h1></div>
<div class="col-sm-3 text-center"><h1>Three</h1></div>
<div class="col-sm-3 text-center"><h1>Four</h1></div>
</div>
</div>
Must Open in Full Page to See Borders!
Added media width clauses in the CSS so there isn't any nasty borders on the mobile-friendly side of things. Hope this helps! This will resize to the length of the longest column. Tested on .col-md-4 and .col-md-6 and my assumption is it is compatible with the rest. No guarantees though.
JSFiddle
.row {
overflow: hidden;
}
.cols {
padding-bottom: 100%;
margin-bottom: -100%;
overflow: hidden;
}
#media(min-width: 992px) {
.col-md-4:not(:first-child),
.col-md-6:not(:first-child) {
border-left: 1px solid black;
}
.col-md-4:not(:last-child),
.col-md-6:not(:last-child) {
border-right: 1px solid black;
margin-right: -1px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<h1>
.col-md-6
</h1>
<hr>
<div class="row text-center">
<div class="col-md-6 cols">
<p>Enter some text here</p>
</div>
<div class="col-md-6 cols">
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
</div>
</div>
<hr>
<h1>
.col-md-4
</h1>
<div class="row text-center">
<div class="col-md-4 cols">
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
</div>
<div class="col-md-4 cols">
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
</div>
<div class="cols col-md-4 cols">
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
<p>Enter some more text here</p>
</div>
</div>
</div>
Assuming you have a column space, this is an option. Rebalance the columns depending on what you need.
<div class="col-1">
<div class="col-6 vhr">
</div>
</div>
.vhr{
border-right: 1px solid #333;
height:100%;
}
As #WalterV answered above, changed for Bootstrap 5+:
<div class="row">
<div class="offset-6 border-start border-5">First</div>
<div class="offset-6 border-start border-5">Second</div>
</div>
As of bootstrap v4 you can use this code
<div class="row">
<div class="col-6 span6 border-right">
dummy content
</div>
<div class="col-6 span6">
right div content
</div>
</div>
In bootstrap 5 you can use the classes border-start or border-end.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<div class="container text-center">
<div class="row">
<div class="col-sm-6 border-end">
<h3>Column 1</h3>
</div>
<div class="col-sm-6">
<h3>Column 2</h3>
</div>
</div>
</div>
Also the borders will not be seen in extra small devices.
<style>
.vl {
border-left: 6px solid green;
height: 500px;
}
</style>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> Vertical Rule </title>
</head>
<body>
<div class="vl"></div>
</body>
</html>
Well what I did was remove the gutter between the respective spans then drawing a left border for the left span and a right border for the right span in such a way that their borders overlapped just to give a single line. This way the visible line will just be one of borders.
CSS
.leftspan
{
padding-right:20px;
border-right: 1px solid #ccc;
}
.row-fluid .rightspan {
margin-left: -0.138297872340425%;
*margin-left: -0.13191489361702%;
padding-left:20px;
border-left: 1px solid #ccc;
}
.row-fluid .rightspan:first-child {
margin-left: -0.11063829787234%;
*margin-left: -0.104255319148938%;
}
HTML
<div class="row-fluid" >
<div class="span8 leftspan" >
</div>
<div class="span4 rightspan" >
</div>
</div>
Try this it works for me
I was looking for a vertical divider in Bootstrap 3.3.7 but they're aren't any by default so I wrote a simple one-line div that did the job for me.
See if it works for you.
<div style="display: inline;border-right: 1px solid gray; padding:0 5px;"></div>
Thank you for reading. Cheers.
Bootstrap V5 introduced the .vr class you place on a <div> element.
If needed, place it inside an <li> element to separate elements inside <ul>element.
<ul class="navbar-nav">
<li>Element 1</li>
<li>
<div class="h-100 vr"></div>
</li>
<li>Element 2</li>
</ul>
Note : .navbar-nav class is related to navbars and sets the css property list-style of all children elements to none which is required for the wrapping <li> element to display the vertical rule (separator) correctly.
Use this, 100% guaranteed:-
vr {
margin-left: 20px;
margin-right: 20px;
height: 50px;
border: 0;
border-left: 1px solid #cccccc;
display: inline-block;
vertical-align: bottom;
}