Making a grid on bootstrap 4 - html

Look at the below attached image.
I am trying to create a grid as showing on image using boostrap4. In destop, first column need to be col-5 width and other 3 equal. In mobile 1st col to be col-12 and other 3 equal.
My HTML:
<div class="row">
<article class="col-5">
<h1 class="text-uppercase">Some Contents</h1>
</article>
<article class="col">
<span class="counter">10</span>
</article>
<article class="col">
<span class="counter">10</span>
</article>
<article class="col">
<span class="counter">10</span>
</article>
</div>
This markup is working on destop. but not in mobile. Hope somebody may help me out.

Need to add breakpoints for small devices
.text-uppercase{
background:#f0f0f0
}
.counter{
background:#f0f0f0;
font-size:68px
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<div class="row">
<article class="col-md-5 col-sm-12">
<h1 class="text-uppercase">Some Contents</h1>
</article>
<article class="col-md col-sm-4">
<span class="counter">10</span>
</article>
<article class="col-md col-sm-4">
<span class="counter">10</span>
</article>
<article class="col-md col-sm-4">
<span class="counter">10</span>
</article>
</div>

You can do it like this, you have to keep in mind that bootstrap is mobile first.
<div class="row">
<article class="col-12 col-md-6">
<h1 class="text-uppercase">Some Contents</h1>
</article>
<article class="col-12 col-sm-4 col-md-2">
<span class="counter">10</span>
</article>
<article class="col-12 col-sm-4 col-md-2">
<span class="counter">10</span>
</article>
<article class="col-12 col-sm-4 col-md-2">
<span class="counter">10</span>
</article>
</div>

Related

I am unable to add images horizontally in my bootstrap website

i'm using bootstrap 5 and the images are not getting aligned in horizontal way. The image gets added in the lower row. i've tried everything nut it dosent's works. any help would be appriciated.
Thank you.
<!-- Bootstrap-5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Body -->
<section>
<div class="container pt-3" class="text1">
<div class="row">
<div class="col-12 text-center ">
<h3> Lots of IT companies in town. Why you should choose us? </h3>
</div>
</div>
</div>
<hr>
</section>
<div class="row">
<div class="col-md-4 text-center">
<img class="img-fluid p-2" src="https://via.placeholder.com/200.jpg" width="150">
<h4 style="font-weight: 700;">Customized requirements</h4>
<p> Every idea is unique and that's we craft it as<br> per your requirements.</p>
</div>
</div>
<div class="col-md-4 text-center">
<img class="img-fluid p-2" src="https://via.placeholder.com/200.jpg" width="150">
<h4 style="font-weight: 700;">Customized requirements</h4>
<p> Every idea is unique and that's we craft it as<br> per your requirements.</p>
</div>
</section>
row div early close
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" />
<section>
<div class="container pt-3" class="text1">
<div class="row">
<div class="col-12 text-center ">
<h3> Lots of IT companies in town. Why you should choose us? </h3>
</div>
</div>
</div>
<hr>
</section>
<div class="container" class="text1">
<section>
<div class="row">
<div class="col-md-4 text-center">
<img class="img-fluid p-2" src="images/our qualities/our_qualities/customized.png" width="150">
<h4 style="font-weight: 700;">Customized requirements</h4>
<p> Every idea is unique and that's we craft it as<br> per your requirements.</p>
</div> <!-- Not Here -->
<div class="col-md-4 text-center">
<img class="img-fluid p-2" src="images/our qualities/our_qualities/customized.png" width="150">
<h4 style="font-weight: 700;">Customized requirements</h4>
<p> Every idea is unique and that's we craft it as<br> per your requirements.</p>
</div>
</div> <!-- Close Here -->
</section>
</div>

Boostrap doesn't want to apply justify-content-between in card

With Bootstrap 4, I am making a horizontal card for classified ad and want in the header to title of the ad to be on the left and price on the right. Using django template:
<section class="card">
<div class="row no-gutters">
<div class="col-sm-4">
<img src="{{ad.thumbnail.url}}" alt="" class="img fluid card-img ad-image-list">
</div>
<div class="col-sm-8">
<div class="card-body">
<header class="d-flex justify-content-between">
<h6>{{ad.title}}</h6>
<h6> {{ad.price}}$ </h6>
<hr>
</header>
<p class="card-text">{{ad.description}}</p>
</div>
</div>
</div>
</section>
I get this:
Why doesnt wanna apply <header class"d-flex justify-content-between"> ?
Because you're using <hr> in flex container and <hr> going to right. Just remove the hr inside header.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<section class="card">
<div class="row no-gutters">
<div class="col-sm-4">
<img src="https://picsum.photos/id/536/354" alt="" class="img fluid card-img ad-image-list">
</div>
<div class="col-sm-8">
<div class="card-body">
<header class="d-flex justify-content-between">
<h6>Title</h6>
<h6>Price</h6>
</header>
<hr>
<p class="card-text">{{ad.description}}</p>
</div>
</div>
</div>
</section>

order directives in bootstrap 4 not working in mobile emulator or mobile device

The order column directive in the following code works when I resize the browser window to mobile width. However, when I run it in mobile emulator or actual mobile device, the order columns are not working. This is due to #media queries not working on mobile. Other solutions on the forum is recommending use of
<meta name="viewport" content="width=device-width,initial-scale=1.0">
However, that meta tag is not helping here.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row align-items-center py-8 py-md-11">
<div class="col-12 col-md-12 col-lg-5 mt-2">
<div class="d-flex">
<div>
<h3>
Feature 1
</h3>
<p>
sometext
</p>
</div>
</div>
<div class="d-flex">
<div>
<h3>
Feature 2
</h3>
<p>
sometext
</p>
</div>
</div>
</div>
<div class="col-12 col-md-12 col-lg-7 order-sm-first order-md-first order-lg-last">
<div class="mb-8 mb-md-0">
<div id="native-awesome-landing-page-tools" class="img-fluid img-animation lottie shadow-dark">
<img class="img-fluid" src="https://upload.wikimedia.org/wikipedia/commons/2/20/Eglinton_Valley_NZ_01.jpg" />
</div>
</div>
</div>
</div>
<div class="row align-items-center py-8 py-md-11">
<div class="col-12 col-md-12 col-lg-7">
<div class="mb-8 mb-md-0">
<img class="img-fluid" src="https://miro.medium.com/max/3000/1*MI686k5sDQrISBM6L8pf5A.jpeg" />
</div>
</div>
<div class="col-12 col-md-12 col-lg-5 mt-2">
<div class="d-flex">
<div>
<h3>
Feature 1
</h3>
<p>
sometext
</p>
</div>
</div>
<div class="d-flex">
<div>
<h3>
Feature 2
</h3>
<p>
sometext
</p>
</div>
</div>
</div>
</div>
Feature 1
sometext
Feature 2
sometext
The code should be entered just after the <head> tag.

HTML bootstrap for displaying images side-by-side?

I want the three images to be side-by-side (on desktop), with the headings and paragraph text to be beneath each respective image.
Does anyone know why it wouldn't be working for me? I presume my code is incorrect somehow
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<div class="portfolio-container">
<section class="portfolio">
<div class="row">
<div class="col-12 my-5">
<h2 class="text-uppercase">Portfolio</h2>
</div>
</div>
<div class="row">
<div class="col-12 col-md-6 col-lg-4">
<div class="media">
<div class="d-none d-sm-block">
<img src="images/whiskey-drop.png" class="rounded-circle mr-3" height=50 width=50>
</div>
<div class="media-body">
<h3>Whiskey Drop</h3>
<h4>HTML, CSS, Bootstrap</h4>
<p>An e-commerce website for a premium whiskey service.</p>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-md-6 col-lg-4">
<div class="media">
<div class="d-none d-sm-block">
<img src="images/rosie-odenkirk.png" class="rounded-circle mr-3" height=50 width=50>
</div>
<div class="media-body">
<h3>Resume</h3>
<h4>HTML, CSS, Bootstrap</h4>
<p>A responsive and user friendly resume showcasing a sample candidate in the best light possible.</p>
</div>
</div>
</div>
<div class="row">
<div class="col-12 d-md-none d-lg-block col-lg-4">
<div class="media">
<div class="d-none d-sm-block">
<img src="images/flappy-bird.png" class="rounded-circle mr-3" height=50 width=50>
</div>
<div class="media-body">
<h3>Flappy Bird</h3>
<h4>Python and Django</h4>
<p>A fun and interactive game where you are in control of a bird as you navigate through tight spaces.</p>
</div>
</div>
</div>
You are creating a new row for every item
Instead, put the col's in one row:
<div class="row">
<div class="col-4">
</div>
<div class="col-4">
</div>
<div class="col-4">
</div>
</div>
You don't need a new <div class="row"></div> around every <div class="col-lg-4"></div>. You can just wrap it around the entire lot to clear the floats.
<div class="row">
<div class="col-12 my-5">
<h2 class="text-uppercase">Portfolio</h2>
</div>
<div class="col-12 col-md-6 col-lg-4">
<div class="media">
<div class="d-none d-sm-block">
<img src="images/whiskey-drop.png" class="rounded-circle mr-3" height=50 width=50>
</div>
<div class="media-body">
<h3>Whiskey Drop</h3>
<h4>HTML, CSS, Bootstrap</h4>
<p>An e-commerce website for a premium whiskey service.</p>
</div>
</div>
</div>
<div class="col-12 col-md-6 col-lg-4">
<div class="media">
<div class="d-none d-sm-block">
<img src="images/rosie-odenkirk.png" class="rounded-circle mr-3" height=50 width=50>
</div>
<div class="media-body">
<h3>Resume</h3>
<h4>HTML, CSS, Bootstrap</h4>
<p>A responsive and user friendly resume showcasing a sample candidate in the best light possible.</p>
</div>
</div>
</div>
<div class="col-12 d-md-none d-lg-block col-lg-4">
<div class="media">
<div class="d-none d-sm-block">
<img src="images/flappy-bird.png" class="rounded-circle mr-3" height=50 width=50>
</div>
<div class="media-body">
<h3>Flappy Bird</h3>
<h4>Python and Django</h4>
<p>A fun and interactive game where you are in control of a bird as you navigate through tight spaces.</p>
</div>
</div>
</div>
</div>
Also make sure that you wrap your height and width values with "" too.

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>