Boostrap 4 Grid System on mobile and desktop - html

I would like to build a grid system using boostrap 4, I have a newspaper that on tablet/desktop mode show three columns each row, instead on mobile mode I would like to show only one column each row.
The documentation to this link https://getbootstrap.com/docs/4.1/layout/grid/
describe the Class prefix across multiple devices.
On tablet/desktop mode everything run well, but on mobile mode I have problems.
This picture show how should be on mobile mode
This pics show the problems that I have on mobile mode
This is the code:
<div class="container">
<div class="row no-gutters">
<!-- Article 1 -->
<div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4">
<div class="content">
<div id='column1' class="column">
Lorem ipsum etc...
</div>
</div>
</div>
<!-- Article 2 -->
<div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4">
<div class="content">
<div id='column2' class="column">
Lorem ipsum etc...
</div>
</div>
</div>
<!-- Article 3 -->
<div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4">
<div class="content">
<div id='column3' class="column">
Lorem ipsum etc...
</div>
</div>
</div>
</div>

Firstly col-sm-12 col-lg-4 col-xl-4 is unnecessary. Bootstrap grid work well. Maybe your title (SERIE BI) is too long. Try to give it max-width: 100%

Just use class="col-4" it's enough
You don't need all these styles col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin="anonymous">
<div class="container">
<div class="row no-gutters">
<!-- Article 1 -->
<div class="col-4">
<div class="content">
<div id='column1' class="column">
Lorem ipsum etc...
</div>
</div>
</div>
<!-- Article 2 -->
<div class="col-4">
<div class="content">
<div id='column2' class="column">
Lorem ipsum etc...
</div>
</div>
</div>
<!-- Article 3 -->
<div class="col-4">
<div class="content">
<div id='column3' class="column">
Lorem ipsum etc...
</div>
</div>
</div>
</div>

Related

How to fit image with col-sm-12 in bootstrap

So there two columns , i wanna fit my image inside my first column so my second column can go down!
enter image description here
my HTML :
<div class="container-fluid">
<div class="row">
<div class="col-lg-6 col-sm-12">
<div class="hero-image container-fluid">
<img class="man-with-laptop img-fluid"
src="https://demo.templateflip.com/super/images/illustrations/hello3.svg" alt="">
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="hero-text-area container-fluid">
<p>HELLO!</p>
</div>
</div>
</div>
</div>
Try it like this below and see what happens.... 1 container, 1 row.
Also, it looks like you're adding a lot of your own CSS I can see from your class types. I think your added CSS is messing about with your layout and confusing Bootstrap.
<div class="container-fluid">
<div class="row">
<div class="col-lg-6 col-sm-12">
<img class="man-with-laptop img-fluid" src="https://demo.templateflip.com/super/images/illustrations/hello3.svg" alt="">
</div>
<div class="col-lg-6 col-sm-12">
<p>HELLO!</p>
</div>
</div>
</div>

Ordering Bootstrap divs

Having trouble with Bootstrap where I have two divs: (A) as col-lg-6 & (B) as col-lg-6 on a large device.
will render: (A)(B)
I am looking to display switch the order of the divs on a mobile or small device? col-sm-12
will render: (B)
(A) *(to display on top of each other)
<section class="about-page">
<div class="container">
<div class="row mineral_padding">
<div class="col-lg-6 col-sm-12 order-1 wow fadeInLeft">
<div class="about_us mineral_margin">
<div class="about_slide">
<div>
<h5>A
</h5>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-sm-12 order-12 wow fadeInRight">B</div>
</div>
</div>
</section>
I am using Bootstrap v4.0.0-alpha.6 (no going back here)
Thanks guys
Basically, this question has been answered before here and here.
In Bootstrap 4 alpha.6 the ordering classes were flex-*, so it would be:
<section class="about-page">
<div class="container">
<div class="row mineral_padding">
<div class="col-lg-6 col-sm-12 flex-last flex-lg-first wow fadeInLeft">
<div class="about_us mineral_margin">
<div class="about_slide">
<div>
<h5>A
</h5>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-sm-12 wow fadeInRight">B</div>
</div>
</div>
</section>
https://www.codeply.com/go/ajPR2ByFVM
As of 4.0 beta, the classes changed to order-* so instead you'd use order-lg-first order-last on the "A" div.
Use order-lg-1 order-sm-0 on B
Use order-lg-0 order-sm-1 on A
https://getbootstrap.com/docs/4.0/utilities/flex/#order
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<section class="about-page">
<div class="container">
<div class="row mineral_padding">
<div class="col-lg-6 col-sm-12 order-lg-0 order-sm-1 wow fadeInLeft">
<div class="about_us mineral_margin">
<div class="about_slide">
<div>
<h5>A
</h5>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-sm-12 order-lg-1 order-sm-0 wow fadeInRight">B</div>
</div>
</div>
</section>

Cannot fit two Jumbotrons Horizontally (Bootstrap)

I'm new to bootstrap and I am having some trouble getting two jumbotrons to sit on one row (without space in between.) No matter how small I make their respective columns, they stay on separate rows.
Here is my HTML:
<div class="col no-gutters">
<div class="col-md-6">
<div class="jumbotron jumbotron-fluid" style="background-color: #e3f2fd;">
<div class="container">
<h1 class="display-4">Title</h1>
<p class="lead">Description. Lorem ipsum dolor sit amet.</p>
</div>
</div>
</div>
<div class="col-md-6">
<div class="jumbotron jumbotron-fluid" style="background-color: #e3f2fd;">
<div class="container">
<h1 class="display-4">Active</h1>
<br>
</div>
</div>
</div>
</div>
I have not messed with the default bootstrap CSS. Thank you in advance!!!
The class of the containing div should to be row, not col:
<div class="row no-gutters">
Bootstrap's Grid system has column spacing (padding) by default. There are a few ways to address this issue to adapt to your requirements.
One approach could be to add a new CSS selector, and then modify your HTML accordingly.
CSS:
/* Add this */
.no-padding {
padding-right:0;
padding-left:0;
}
HTML:
<div class="col">
<div class="col-md-6 no-padding"> <!-- add no-padding -->
<div class="jumbotron jumbotron-fluid" style="background-color: #e3f2fd;">
<div class="container">
<h1 class="display-4">Title</h1>
<p class="lead">Description. Lorem ipsum dolor sit amet.</p>
</div>
</div>
</div>
<div class="col-md-6 no-padding"> <!-- add no-padding -->
<div class="jumbotron jumbotron-fluid" style="background-color: #e3f2fd;">
<div class="container">
<h1 class="display-4">Active</h1>
<br>
</div>
</div>
</div>
</div>

Bootstrap column alignment in mobile

I have multiple columns in a single div without row. I achieved to move the column down if its has title . But next div can't comes automatically to right side.
<div class="secn-frst1">
<div class="col-sm-3 col-xs-6">
<h3>no title</h3>
//content
</div>
<div class="col-sm-3 col-xs-6">
<h3>have title</h3>
//content
</div>
<div class="col-sm-3 col-xs-6">
<h3>no title</h3>
//content
</div>
<div class="col-sm-3 col-xs-6">
<h3>no title</h3>
//content
</div>
<div class="col-sm-3 col-xs-6">
//have title
</div>
</div>
<div class="secn-frst2">
<div class="col-sm-3 col-xs-6">
<h3>no title</h3>
//content
</div>
<div class="col-sm-3 col-xs-6">
<h3>have title</h3>
//content
</div>
<div class="col-sm-3 col-xs-6">
<h3>no title</h3>
//content
</div>
<div class="col-sm-3 col-xs-6">
//have title
</div>
</div>
I applied display:block and clear:both for col-xs-6 to move down if it has title (for 2nd column) but the 3rd column not coming to right side like left and right. I need to do this without row because of all column should randomly appears to left and right.
Here my site
screen for ref
Divide each sections with titles with a container-fuild and add a row.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<div class="container-fluid">
<div class="secn-frst1">
<div class="col-sm-3 col-xs-6">
<img src="http://mobilegear.my/alphatiles/assets_user/product/alpha_2018-01-12744.png">
</div>
</div>
</div>
<div class="container-fluid">
<h3>have title</h3>
<div class="col-sm-3 col-xs-6">
<img src="http://mobilegear.my/alphatiles/assets_user/product/alpha_2018-01-12744.png">
</div>
<div class="col-sm-3 col-xs-6">
<img src="http://mobilegear.my/alphatiles/assets_user/product/alpha_2018-01-12744.png">
</div>
<div class="col-sm-3 col-xs-6">
<img src="http://mobilegear.my/alphatiles/assets_user/product/alpha_2018-01-12744.png">
</div>
</div>
<div class="container-fluid">
<h3>have title</h3>
<div class="col-sm-3 col-xs-6">
<img src="http://mobilegear.my/alphatiles/assets_user/product/alpha_2018-01-12744.png">
</div>
</div>
<hr>
<div class="container-fluid">
<div class="secn-frst2">
<div class="col-sm-3 col-xs-6">
<img src="http://mobilegear.my/alphatiles/assets_user/product/alpha_2018-01-12744.png">
</div>
</div>
</div>
<div class="container-fluid">
<h3>have title</h3>
<div class="col-sm-3 col-xs-6">
<img src="http://mobilegear.my/alphatiles/assets_user/product/alpha_2018-01-12744.png"> </div>
<div class="col-sm-3 col-xs-6">
<img src="http://mobilegear.my/alphatiles/assets_user/product/alpha_2018-01-12744.png"> </div>
</div>
<div class="container-fluid">
<h3>have title</h3>
<div class="col-sm-3 col-xs-6">
<img src="http://mobilegear.my/alphatiles/assets_user/product/alpha_2018-01-12744.png">
</div>
</div>

Bootstrap 3 Vertical Alignment Across Multiple Rows and Columns

I am new to Bootstrap. I just started a project and came across a challenge regarding vertical alignment with Bootstrap's grid system. Hopefully this community of experts will be able to shed some light and assist with a solution.
To better illustrate the issue, I have taken 4 screenshots (links attached at the bottom) for each of the lg, md, sm, and xs scenarios. I hope the images make sense to you.
The problem is, while the lg scenario looks great and everything is aligned properly, as the viewport changes, the content of the 2 columns start to show misalignment.
Here is the HTML markup:
<div class="container">
<div class="row row-centered">
<div class="col-sm-6 col-md-6 col-lg-6">
<div class="row row-centered">
<div class="hidden-xs hidden-sm hidden-md hidden-lg"></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<h2>HEADER NUMBER 1</h2>
</div>
<div class="hidden-xs hidden-sm hidden-md hidden-lg"></div>
</div>
<div class="row row-centered">
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2"></div>
<div class="col-xs-8 col-sm-8 col-md-8 col-lg-8">
<div>
<p>Teaser number 1 - Lorem ipsum dolor sit, interdum consectetur elit. Donec interdum dapibus lectus rhoncus.</p>
</div>
</div>
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2"></div>
</div>
<div class="row row-centered">
<div class="col-sm-6 col-md-6 col-lg-6">
<img class="img-responsive" src="http://placehold.it/200x200&text=Square" alt="">
<h4>Sub-heading short</h4>
</div>
<div class="col-sm-6 col-md-6 col-lg-6">
<img class="img-responsive" src="http://placehold.it/200x200&text=Square" alt="">
<h4>Sub-heading longer</h4>
</div>
</div>
<div class="row row-centered">
<div class="col-lg-12">
<div>
<p>Link to detailed page 1</p>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-md-6 col-lg-6">
<div class="row row-centered">
<div class="hidden-xs hidden-sm hidden-md hidden-lg"></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<h2>HEADER DIFFERENT LENGTH</h2>
</div>
<div class="hidden-xs hidden-sm hidden-md hidden-lg"></div>
</div>
<div class="row row-centered">
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2"></div>
<div class="col-xs-8 col-sm-8 col-md-8 col-lg-8">
<div>
<p>Teaser number 2 - Lorem ipsum dolor sit amet. Donec interdum dapibus lectus eu rhoncus.</p>
</div>
</div>
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2"></div>
</div>
<div class="row row-centered">
<div class="col-sm-6 col-md-6 col-lg-6">
<img class="img-responsive" src="http://placehold.it/200x200&text=Square" alt="">
<h4>Sub-heading different</h4>
</div>
<div class="col-sm-6 col-md-6 col-lg-6">
<img class="img-responsive" src="http://placehold.it/200x200&text=Square" alt="">
<h4>Sub-heading 4</h4>
</div>
</div>
<div class="row row-centered">
<div class="col-lg-12">
<div>
<p>Link to detailed page number 2</p>
</div>
</div>
</div>
</div>
</div>
</div>
I have not incorporated any custom CSS yet except for the .row-centered, which is as simple as this:
.row-centered {
text-align:center;}
What should I do to fix the problem? Thank you very much!
Here are the screenshots:
Example
Topgun, Hi there. To get this to stay inline with each other.
My approach is to adjust the title font size at 2 media breakpoints.
You can change this to suit what suits you, I went just a little smaller to show the effect here.
I also at a breakpoint add the height value to main text part you have too.
I used min-height here rather than a fixed height. Because when they stack on a small screen the text need room to expand down.
Your code had lost of extra divs and seemed like lots of hidden block padders.
I went through this and removed a lot just to pull it back to what is only needed here for this demo.
Go through the code and see the difference.
What I also added here was col-xs-12 into your img class.
As you will see now when resized down to a small screen size the image goes full width and does not stay to the left with a big space to the right.
To center the text you just need to use the class of text-center once in each of the 2 rows.
Hope that this gets you started for how you want it to look now.
Here is the Fiddle.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>Starter Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<style>
body {
padding-top: 50px;
}
.spacer {
margin-top: 2%;
margin-bottom: 2%;
}
#media(max-width:1200px) {
.adjust-fontsize{
font-size:2em;
font-weight: 700;
font-weight: 600;
}
}
#media(max-width:992px) {
.adjust-fontsize{
font-size:1.0em;
}
.row-height{
min-height:70px;
}
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand " href="#">Project name</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container col-lg-12 spacer"></div>
<div class="container col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 text-center">
<div class="row col-lg-12">
<h2 class="adjust-fontsize">HEADER NUMBER 1</h2>
</div>
<div class="row col-lg-12 row-height">
<p>Teaser number 1 - Lorem ipsum dolor sit, interdum consectetur elit.
Donec interdum dapibus lectus rhoncus.
</p>
</div>
<div class="row col-lg-12">
<div class="col-xs-12 col-sm-6">
<img class="col-xs-12 img-responsive" src="http://placehold.it/200x200&text=Square" alt="">
<h4>Sub-heading short</h4>
</div>
<div class="col-xs-12 col-sm-6">
<img class="col-xs-12 img-responsive" src="http://placehold.it/200x200&text=Square" alt="">
<h4>Sub-heading longer</h4>
</div>
</div>
<div class="row col-xs-12">
<p>Link to detailed page 1</p>
</div>
</div>
<div class=" col-xs-12 col-sm-6 col-md-6 col-lg-6 text-center">
<div class="row col-lg-12">
<h2 class="adjust-fontsize">HEADER DIFFERENT LENGTH</h2>
</div>
<div class="row col-xs-12 row-height">
<div class="col-xs-12">
<p>Teaser number 2 - Lorem ipsum dolor sit amet.
<br>Donec interdum dapibus lectus eu rhoncus.
</p>
</div>
</div>
<div class="row col-lg-12">
<div class="col-xs-12 col-sm-6">
<img class="col-xs-12 img-responsive" src="http://placehold.it/200x200&text=Square" alt="">
<h4>Sub-heading different</h4>
</div>
<div class="col-xs-12 col-sm-6">
<img class="col-xs-12 img-responsive" src="http://placehold.it/200x200&text=Square" alt="">
<h4>Sub-heading 4</h4>
</div>
</div>
<div class="row col-xs-12">
<p>Link to detailed page number 2</p>
</div>
</div>
</div><!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</body>
</html>