Stacking using boostrap Grid System - html

I am building a header using Bootstrap. I'm trying to make the desktop version spread out over the full 12 grid like so:
Then on the phone I'm wanting to having the two stack like shown below:
This is the way I've been trying to accomplish so far with bootstrap but I am not having much luck: Any feedback or suggestions appreciated!
<div class="container-fluid">
<div class="background row">
<div class="col-lg-1 col-xs-12">
<p class="text-center">gb</p>
</div>
<div class="col-lg-1 col-xs-12">
<p class="text-center">us</p>
</div>
<div class="col-lg-6 col-xs-12">
<p class="text-center announce-something-h">ANNOUNCE SOMETHING HERE</p>
</div>
<div class="col-lg-4 col-xs-12">
<p class="text-center announce-something-h">UK</p>
</div>

Just use floats and media queries:
.header{
background-color:grey;
overflow:hidden;
}
.header__left, .header__right, .header__message{
padding:10px;
}
.header__left{
float:left;
}
.header__right{
float:right;
}
.header__message{
text-align:center;
background-color:red;
}
#media(max-width:767px){
.header__message{
clear:both;
}
}
<header class="header">
<div class="header__left">
GB
USD
</div>
<div class="header__right">
UK
</div>
<div class="header__message">Announce Something here</div>
</header>
live example:
https://codepen.io/anon/pen/PdXBZR

Related

Bootstrap columns overlapping on small screens

I have 2 columns and on the left and the right side, When I open the web page on a small or xs screen the two columns overlap. I would like for the other column to go below the other.
<div class="container">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-9 area-style"></div>
</div>
</div>
CSS:
.area-style {
border: 1px solid #ccc;
padding-top: 2em;
background: #fafafa;
height: 500px;
}
Please check if you have given floats to the elements inside any of the "col-md-3" or "col-md-9" divs. The Overlapping 99% occurs If the floats are not cleared.
If you are using Bootstrap4 try this.
<div class="container">
<div class="row">
<div class="col-12 col-md-3"></div>
<div class="col-12 col-md-9 area-style"></div>
</div>
</div>
Try this.
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-3"></div>
<div class="col-xs-12 col-md-9 area-style"></div>
</div>
</div>
Please tell me if this helps you.

Right column on top in Bootstrap on mobile platform

I'm trying to get the right div to be on top when viewed on a mobile device using Bootstrap, as explained and answered in this thread, meaning I want my desktop layout to look as follows:
A | B
And my mobile layout as follows:
B
A
However, the proposed following solution isn't working for me:
<div class="row">
<div class="col-md-6 col-md-push-6">B</div>
<div class="col-md-6 col-md-pull-6">A</div>
</div>
My code looks as follows:
<section id="kalender" class="kalender-section content-section text-center">
<div class="container">
<div class="row">
<div class="col-lg-4 col-lg-push-8 mx-auto">
B
</div>
<div class="col-lg-8 col-lg-push-4 mx-auto">
A
</div>
</div>
</div>
</section>
But B is still shown on the left on a desktop view.
Any ideas on what I'm doing wrong, and how to fix this? Thank you in advance.
You are using col-lg-push on both div. Use col-lg-pull-4 on your second div "A"
So your new code is:
<section id="kalender" class="kalender-section content-section text-center">
<div class="container">
<div class="row">
<div class="col-lg-4 col-lg-push-8 mx-auto">
B
</div>
<div class="col-lg-8 col-lg-pull-4 mx-auto">
A
</div>
</div>
</div>
</section>
Working JSFiddle: https://jsfiddle.net/v5a7ommf/1/
Follow below code:
https://codepen.io/hardiksolanki/pen/GOKGOx
Desktop view: A | B
Mobile view:
B
A
This can also possible with out boo-trap.
.desktop-left{
background: red;
float: right;
}
.desktop-right{
background: green;
float: left;
}
#media only screen and (max-width:980px) {
.desktop-right, .desktop-left{
float: none;
}
}

How to stack Bootstrap row inside of another row?

I have a Bootstrap page on which I'm trying to stack different boxes.
Imgur - Image of boxes (sorry, not enough rep to upload images directly)
The green boxes are the ones currently in position, and the red ones are the ones I am having issues with. I'm using the following code (simplified) to get the green boxes:-
<div class="container">
<div class="row">
<div class="col-xs-3" style="height:100px; background-color:green;">
</div>
<div class="col-xs-3" style="height:100px; background-color:green;">
</div>
<div class="col-xs-6" style="height:200px; background-color:green;">
</div>
</div>
</div>
I'm basically trying to create another two <div class="col-xs-3" style="height:100px; background-color:green;"> that will go underneath the current two, while also keeping the large box to the right.
I thought it would be an easy fix with a new row, or using float:left / right, but none of that seems to be working out.
One way to do it would be to make two 50% width columns and then divide the column on the right into two rows with two more columns in each:
.green-lrg {
background-color:green;
height:215px;
}
.green-sml {
background-color:green;
height:100px;
}
.red-sml {
background-color:red;
height:100px;
}
.col-xs-6 .row {
padding-top:15px;
}
.col-xs-6 .row:first-child {
padding-top:0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<!-- LEFT COLUMN -->
<div class="col-xs-6">
<div class="green-lrg"></div>
</div>
<!-- RIGHT COLUMN -->
<div class="col-xs-6">
<div class="row">
<div class="col-xs-6">
<div class="green-sml"></div>
</div>
<div class="col-xs-6">
<div class="green-sml"></div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="red-sml"></div>
</div>
<div class="col-xs-6">
<div class="red-sml"></div>
</div>
</div>
</div>
</div>
</div>
Here is simple example.
HTML
<div class="container">
<div class="row">
<div class="col-xs-6 box box-big">
</div>
<div class="col-xs-6">
<div class="row">
<div class="col-xs-6 box box-small">
</div>
<div class="col-xs-6 box box-small">
</div>
<div class="col-xs-6 box box-small">
</div>
<div class="col-xs-6 box box-small">
</div>
</div>
</div>
</div>
</div>
and CSS:
.box {
background-color:green;
border:5px solid white;
}
.box-big {
height:200px;
}
.box-small {
height:100px;
}

How to stretch image based on right side?

I have this demo : https://jsfiddle.net/DTcHh/18752/ I want that image height is based on right side so that image always goes to the end of div. Any suggestion?
<div class="blog_list">
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="blog_image">
<img src="img/property_img.png" />
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="blog_details">
<div class="blog_title">This comfortable apartment is located in the heart of Zurich</div>
<div class="blog_posted">POSTED ON: <span>JANUARY 24 2016 14:35h </span>IN <span>KREIS 1</span></div>
<p class="blog_more-details">
Wheather a single room studio or multi-room apartment, each has at least one own bathroom and a fully quipped kitches.
</p>
<div class="sold_by">
<div class="row">
<div class="col-md-12 col-sm-12">
<div class="row">
<div class="col-md-2 col-sm-2 col-xs-12 ">
<div class="profile-image"><img src="img/profile.png" /></div>
</div>
<div class="col-md-10 col-sm-10 col-xs-12 no-padding-left">
<span class="property">ARTICLE WRITEN BY</span>
<span class="property_name">Janine Lindenmuller</span>
<div class="blog_read_more">
READ MORE
</div>
</div>
</div>
</div>
</div></div></div></div></div></div>
i think u need to remove bootstrap grid class and have to write some custom css with display:table-cell
for example
.img,.text {
display: table-cell;
vertical-align: top;
}
.img {
width:60%;
}
.text {
width:40%;
}
Also use low dimension image. Fiddle here
Set your image row like this:
JSFiddle
<div class="col-md-12 col-sm-12 col-xs-12">

Centre align div content in bootstrap

I want my date picker to be in the middle of the page, eg. the line where I have: <div class="center-block text-center datepicker"></div>
Obviously center-block and text-center I tried already - but neither change anything. And with the offset it just makes it close to the centre without being perfectly centre aligned.
What do I need to do?
Thanks
<div class='row'>
<div class='col-sm-12'>
<div class='page-header page-header-with-icon mg-t'> <i class='fa-icon-calendar'></i>
<h2>Calendar</h2>
</div>
<div class="row">
<div class="col-sm-4 col-sm-offset-4">
<div class="center-block text-center datepicker"></div>
</div>
</div>
</div>
</div>
Try something like this:
<div class="col-sm-12">
<div class="datepicker"></div>
</div>
Then give the date picker something like:
.datepicker {
display:inline-block;
margin:0 auto;
}
I haven't tested this, but it would be where I would start.
style="text-align:center;" shall do the trick no? I tested and for me, the "CALENDAR" text is centered
<div class="col-sm-12">
<div class="page-header page-header-with-icon mg-t" style="text-align:center;">
<i class="fa-icon-calendar"></i>
<h2>Calendar</h2>
</div>
<div class="row">
<div class="col-sm-4 col-sm-offset-4">
<div class="center-block text-center datepicker"></div>
</div>
</div>
</div>
</div>
This is what should solve your problem. Add it somewhere in your custom stylesheet and change the width % to what suits your design.
.datepicker-inline {
width: 20%;
}