Why is Bootstrap 4 column not taking its full available width? - html

I have the following page structure:
<div class="container">
<div class="row mb-5">
<div class="col-12 col-md-3">
<img class="mr-5 img-fluid" src="big_icon_1.png" alt="Big icon 1">
</div>
<div class-"col-12 col-md-9">
<h3 class="mt-0 mb-1 text-center text-md-left">Item 1</h3>
<p>This is item 1.</p>
</div>
</div>
<div class="row mb-5">
<div class="col-12 col-md-3">
<img class="mr-5 img-fluid" src="big_icon_2.png" alt="Big icon 2">
</div>
<div class-"col-12 col-md-9">
<h3 class="mt-0 mb-1 text-center text-md-left">Item 2</h3>
<p>This is item 2.</p>
</div>
</div>
</div>
What I am expecting is a column layout from the 'md' breakpoint up, and a stacked layout below that, and this is indeed what I'm getting. But the second 'col' is never extending to the right edge of the parent 'row' container and I do not understand why as all of the examples in the Bootstrap documentation show exactly that this should happen.
So my icon column is nicely set to 1/4 row width on a desktop and full width on mobile. But the column with heading and text is only ever as wide as its content, no matter what size the display. Of course, this makes the heading centring pointless.
What am I missing?

The source formatter on this website failed to catch this little gem, and my source editor has a very subtle colour difference that I hadn't noticed:
<div class-"col-12 col-md-9">
Which should, of course, be
<div class="col-12 col-md-9">
Time to change my editor colour scheme.
And, in fact, that line doesn't need the col-12 class in case anyone is looking. I only put it there in desperation.

Related

How to center items in container grid

How can I center text and image?
Here is my code
<div class="container my-5">
<div class="row py-4 justify-content-center">
<div class="col-lg-4 mb-4">
<h1 class="text-dark font-weight-bold mb-3">
We've been expecting you
</h1>
<p class="mb-4">At our core is a collection of design and development solutions</p>
</div>
<div class="col-lg-8"><img src='assets/about.png' class="w-80"></div>
</div>
</div>
I tried to implement justify-center, offset,ml-x ,but nothing seems to work? I've already read the bootstrap library and haven't found anything that could help me
In your row, you have a 4 column wide column and an 8 column wide column, so you’re already taking up the full 12 columns, so the content in the row won’t “center.”
Your image will be whatever width it is as w-80 isn’t a Bootstrap 4 class – try w-75 or add your own class for w-80 (although if the image is only 80% of the column, the column won’t look centered - the content is already taking up the full width).
You could make the two columns 3 & 7, and then use a 1 column offset to have the two columns in the center (with the image at 100% of the 7 column width).
<div class="container my-5">
<div class="row py-4">
<div class="col-lg-3 offset-lg-1 mb-4">
<h1 class="text-dark font-weight-bold mb-3">
We've been expecting you
</h1>
<p class="mb-4">At our core is a collection of design and development solutions</p>
</div>
<div class="col-lg-7"><img src='bg400x240-1.png' class="w-100"></div>
</div>
</div>

Trying to align items horizontally on large displays, and vertically on small displays with bootstrap

On large displays: I have an image horizontally aligned with 2 headers.
On small displays: I'm trying to stack the headers underneath the image, aligned vertically.
I suspect it has something to do with either margins, flex direction, some type of align property. Idk.. I've tried a bunch of things, maybe just not the right combination of things. It's possible i'm just having a brain fart or something. Here's the code:
<section>
<div class="container-md d-lg-flex align-items-center align-middle">
<img src="images\logo2.png" class="img-adjustment">
<div class="heading-wrapper">
<div class="display-4 montserrat text-nowrap heading-adjustment" style="">
Phoenix Master Meters
</div>
<h5 class="source-sans text-nowrap heading-adjustment">
Pipeline Consulting, Inspection, and Maintenance Services
</h5>
</div>
</div>
</section>
You can implement Bootstrap Grid, which then will handle display for large and small screens.
Then, remove text-nowrap class in elements inside heading-wrapper div.
This is one example
<section>
<div class="container-md d-lg-flex align-items-center align-middle">
<div class="row">
<div class="col-lg-2 col-sm-12">
<img src="images\logo2.png" class="img-adjustment">
</div>
<div class="col-lg-10 col-sm-12">
<div class="heading-wrapper">
<div class="display-4 montserrat heading-adjustment" style="">
Phoenix Master Meters
</div>
<h5 class="source-sans heading-adjustment">
Pipeline Consulting, Inspection, and Maintenance Services
</h5>
</div>
</div>
</div>
</div>
</section>

Bootstrap Columns Vertical stacking

In my post section of the web site which I am creating I have 4 columns with post in each post with different height based on it's contents . bootstrap 4 grid system. As per photo under
When I resize the 4th column re-arrange.
As u can see on the above image the 4th column is shifted under number 1 but its align base on the height of the 3rd column. I want to be stacked like the photo bellow.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row pt-3 port-folio-margins pb-5 pr-4 pl-4">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 pl-1 pr-1 ">
<div class="post-container">
<div class="post-image"> </div>
<div class="post-title">TEST2016</div>
<div class="post-share-icons"></div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 pl-1 pr-1 ">
<div class="post-container">
<div class="post-image"> </div>
<div class="post-title">TEST2016</div>
<div class="post-share-icons"></div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 pl-1 pr-1 ">
<div class="post-container">
<div class="post-image"> </div>
<div class="post-title">TEST2016</div>
<div class="post-share-icons"></div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 pl-1 pr-1 ">
<div class="post-container">
<div class="post-image"> </div>
<div class="post-title">TEST2016</div>
<div class="post-share-icons"></div>
</div>
</div>
So the question is how to achieve that CSS formatting with Bootstrap or without bootstrap . I have tried putting "float" using "flex wrap" also "clearfix" without result.
Bootstrap has a built in utility for this problem you can use cards and wrap them in card columns. See the documentation here
This is a tricky issue that is often just worked around. Web-pages are much easier to code in grids, so things tend to be in columns and rows. In your example, when wrapped the row needs to be tall enough to contain your third item. That means that if the fourth item sat where you want it, it would be within the cell of the first item.
You can use something like Masonary, which I believe calculates top and left positions as you resize. Or I think you can use flex and a whole lot of wrapper divs, but that will get messy and be horrible maintenance. It's so messy I've never got it into production, either because I lost my mind trying, or hated the thought of maintaining it when it was working in just a small example.
Masonary allows a fairly simple layout
<div class="grid">
<div class="grid-item"></div>
<div class="grid-item grid-item--height2"></div>
<div class="grid-item grid-item--height3"></div>
<div class="grid-item grid-item--height2"></div>
</div>
JSFiddle example

How to make image scale to full width on bootstrap column after transition to mobile view

I'm struggling with making the image on the right stretch to full width in a moment when you'll make the screen size smaller so it transitions to mobile view.
Is there any other class in bootstrap that would do similar work that "img-fluid" does but display image full width when it goes below the text in bootstrap grid system?
<div class="row">
<div class="col-md-6 d-flex">
<div class="align-self-center">
<p class="lead font-weight-bold">sometext</p>
</div>
</div>
<div class="col-sm-6">
<img class="img-fluid" src="someimage.jpg">
</div>
</div>
Here is my fiddle: http://jsfiddle.net/x1hphsvb/2220/
To see what I mean simply lower the width of display window. Image goes below the text and fills only half of the div when I want it to fill it fully and behave as it does right now before the transition.
Both the columns should have the same breakpoint (ie; md/sm) so that they become full-width at the same time...
<div class="row">
<div class="col-md-6 d-flex">
<div class="align-self-center">
<p class="lead font-weight-bold">sometext</p>
</div>
</div>
<div class="col-md-6">
<img class="img-fluid" src="someimage.jpg">
</div>
</div>
http://jsfiddle.net/dwnu5zjq/

Bootstrap 3 -Images and text floated to opposite sides of a responsive column

I looked and haven't found my specific problem. I'm trying to build a responsive webpage, with a lg layout that has 12 images with text below them, a med and a sm layout with text and pics next to each other, and an xs layout with images above text again.
I cannot get the images and the paragraphs to sit beside each other in the column. I've tried push-x, pull-x, offset-x, media queries where I made a div for each .img and .p and made them float.
I'm sure there's an easy way to do it, but this is my first week of Bootstrap, and I can't figure it out. How is this done?
Here's a sample of my code:
<div class="row">
<div class="content col-lg-2 col-md-4 col-sm-6 col-xs-12">
<h2>Fork and Spoon</h2>
<div class="frame1"><img class="img-responsive" src="./images/spork.jpg" alt="Spork"></div>
<p>We are the <em>spork of the party!</em> Yes, we've endured most every cutting remark; just don't refer to my wife as "flatware" and she is happy. </p>
<p><a class="btn btn-default" href="#">More utensils here »</a></p>
</div>
Put a grid inside your larger grid. Code below, working example at http://bootply.com/91851
<div class="row">
<div class="content col-lg-2 col-md-4 col-sm-6">
<h2>Fork and Spoon</h2>
<div class="row">
<div class="col-lg-12 col-sm-6">
<img class="img-responsivet" src="./images/spork.jpg" alt="Spork">
</div>
<div class="col-lg-12 col-sm-6">
<p>We are the <em>spork of the party!</em> Yes, we've endured most every cutting remark; just don't refer to my wife as "flatware" and she is happy. </p>
</div>
</div>
<p><a class="btn btn-default" href="#">More utensils here »</a></p>
</div>
...repeat...
</div><!--/row-->
Also note that you do not need to explicitly set .col-xs-12, as this is the default if you do not set col-xs at all.