Automatically resize items when minimizing window - html

Hello i'm working on a project and i got a problem.
My "items" (which are divs) get out of the container when i minimize my window.
My code is a bit weird but it's working so far, here's where are my items.
<div class="containerpage">
<div class="container">
<div class="artcontainer">
<div class="row">
<div class="container">
<div class="col-md-10">
<div class="col-sm-4 col-md-4">
<div class="post">
<div class="post-img-content">
<img src="http://placehold.it/460x250/e67e22/ffffff&text=HTML5" class="img-responsive" />
<span class="post-title"><b>Make a Image Blur Effects With</b><br />
<b>CSS3 Blur</b></span>
</div>
<div class="content">
<div class="author">
By <b>Bhaumik</b> |
<time datetime="2014-01-20">January 20th, 2014</time>
</div>
<div>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
Ipsum has been the industry's standard dummy text ever since the 1500s, when an
unknown printer took a galley of type and scrambled it to make a type specimen book.
</div>
<div>
Read more
</div>
</div>
</div>
</div>
</div>
<!-- Same col-sm-4 col-md-4 several times on col-md-10 that make my "thumbnails"-->
<div class="col-md-2">
<!-- Image that you can see on the right -->
</div>
</div>
</div>
</div>
</div>
Now what i get when i minimize my window : http://i.stack.imgur.com/wid7y.jpg
As you can see my blocs (HTML5) are outside of the container, plus there's a grey space at the right that blocks another image (which is in the col-md-2), can this be from a margin or padding on the body or main part ?
Every other elements on the site automatically resize themselves but no this part, where is my mistake ? Is this from the CSS ?
I'd actually like my items not to be smaller when i minimize but instead having one by row automatically when minimizing.
-- Also i've always used col-md most of the times, is there an equivalence for smaller screens that i should precise when i make my col ?
I hope i've been clear enough (:

Try adding the following line to your css class for the DIV elements:
display: inline-block;
This should make the DIVs to go down a row if they don't have enough room.

You can achieve spacing between columns using the col-xs-* classes,within in a col-xs-* div coded below. The spacing is consistent so that all of your columns line up correctly. To get even spacing and column size I would do the following:
( Note : You can Use col-xs-* or col-md-* or col-sm-* . i used col-xs-*)
<div class="container">
<div class="col-md-3 ">
<div class="col-md-12 well">
Some Content..
</div>
</div>
<div class="col-md-3 ">
<div class="col-md-12 well">
Some Second Content..
</div>
</div>
<div class="col-md-3 ">
<div class="col-md-12 well">
Some Second Content..
</div>
</div>
<div class="col-md-3 ">
<div class="col-md-12 well">
Some Second Content..
</div>
</div>
<div class="col-md-3 ">
<div class="col-md-12 well">
Some Second Content..
</div>
</div>
<div class="col-md-3 ">
<div class="col-md-12 well">
Some Second Content..
</div>
</div>
<div class="col-md-3 ">
<div class="col-md-12 well">
Some Second Content..
</div>
</div>
<div class="col-md-3 ">
<div class="col-md-12 well">
Some Second Content..
</div>
</div>
</div>

Great Keval Bhatt, i changed width px to % and it worked almost perfectly !
I also tried display: inline-block; but when i minimized, my items were "behind" the container so they disappeared.
Changing px to % worked, thanks again ! (:

Related

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

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.

bootstrap v4 push pull gone

Looking at bootstrap v4 updates:
https://getbootstrap.com/docs/4.0/migration/#grid-system-1
...Dropped push and pull modifier classes for the new flexbox-powered order classes. For example, instead of .col-8.push-4 and .col-4.pull-8, you’d use .col-8.order-2 and .col-4.order-1.
But when I use the order function it doesn't seem to work the same as the push pull method. It stacks the rows up just like the first row in the code below.
My goal is to have a img on the left with text on the right on one row then text on the left and a img on the right on the next row on a desktop. When its resized in a smaller screen I would like each image stacked on top of the text it corresponds with.
<div class="container">
<div class="row">
<div class="col-md-4">
<!--img-->
</div>
<div class="col-md-8">
<!--text-->
</div>
</div>
<div class="row">
<div class="col-md-8 order-2">
<!--text-->
</div>
<div class="col-md-4 order-1">
<!--img-->
</div>
</div>
</div>
If you want to change order for example on md you can define first normal order for that size and then order-n for all smaller sizes. So your code should look like this.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-md-4">
img
</div>
<div class="col-md-8">
text
</div>
</div>
<div class="row">
<div class="col-md-8 order-2 order-md-1">
text
</div>
<div class="col-md-4 order-1 order-md-2">
img
</div>
</div>
</div>

Text appears in two lines when browser width gets smaller

My issue is that the text starts to appear in two lines when browser width gets a little smaller.
I am using the bootstrap grid system... so shouldn't the text be adjusted within the grid?
I tried changing:
<div class="row">
To
<div class="row col-sm-12">
but same result.
My code snippet:
<div class="row">
<div class="col-sm-8">
<p>Posted by admin on this this date</p>
</div>
<div class="col-sm-4">
<p class="text-right">One comment</p>
</div>
</div>
Screenshot of issue:
JSFiddle Demo
Change sm to xs.
So now your code look like this:
<div class="row">
<div class="col-xs-8">
<p>Posted by admin on this this date</p>
</div>
<div class="col-xs-4">
<p class="text-right">One comment</p>
</div>
</div>
You have to read the Bootstrap CSS documentation first. It is clearly stated that .col-sm- column prefix will work starting from the width of Small Devices Tablets (≥768px).
Like Rizki said. You need to change col-sm-4 and col-sm-8 to this
<div class="row">
<div class="col-xs-8">
<p>
Posted by admin on this this date</p>
</div>
<div class="col-xs-4">
<p class="align-right">One comment</p>
</div>
</div>
Check it out in action -- https://jsfiddle.net/aLuv47bt/
Cheers.
Change col-sm tp col-xs to make it in one line. Here is the code.
<div class="row">
<div class="col-xs-8">
<p>Posted by admin on this this date</p>
</div>
<div class="col-xs-4">
<p class="text-right">One comment</p>
</div>
</div>
simple fix this with white-space:nowrap
p {
white-space:nowrap;
}
p {
white-space:nowrap;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="row">
<div class="col-sm-8">
<p>
Posted by admin on this this date</p>
</div>
<div class="col-sm-4">
<p class="text-right">One comment</p>
</div>
</div>
Check with demo
https://jsfiddle.net/x9g2th82/4/

twitter bootstrap - minimum width column?

this has to have been asked before, but i don't think my "terms" are correct.
i have a page that has text, and then an image. When the image ends, i would like the text to flow under the image.
So,
<div class="row">
<div class="col-xs-10 col-xs-offset-1 ">
<div class="hero-unit row">
<div class="col-xs-12 ">
<h2 class="welcome">welcome</h2>
</div>
<div class="col-xs-8 ">
<p>some text here</p>
<p>imagine there is more text here</p>
<p>just, the most text ever.</p>
</div>//col-xs-8
<div class="solidClass col-xs-4 ">
<img class="img-responsive" src="/WebContent/img/both.png" alt="screenshots"/>
</div>
</div>//hero-unit-row
</div> //col-xs-10
</div>//row
in the scenario above, the text in the "col-xs-8" row should overflow when the text gets past the image in the col-xs-4 row.
is there something i can tell bootstrap by way of a class, or something i can add to a specialty class to make this happen?
The structure you would need for this layout is the next:
<div class="col-xs-12">
<div class="solidClass col-xs-4 pull-right">
<img class="img-responsive" src="http://lorempixel.com/100/100" alt="screenshots" />
</div>
<p>some text here</p>
<p>imagine there is more text here</p>
<p>just, the most text ever.</p>
</div>
Demo: http://plnkr.co/edit/vSq4rsJPbjfvdn6FYiR9?p=preview
Two important points:
Extend "left" text container to full width with .col-xs-12 class.
Move image container into text container and float it right with pull-right class.
In order for your intended effect, the image has to be in the same parent element as the text.
You can then use bootstrap's pull-right class to float the element to the right.
I, also, assume that you intended for the text to be able to fit the full 12 col width. If you want the image to still be limited to a 4 column width, you can wrap it in a bootstrap col-xs-4 class.
<div class="row">
<div class="col-xs-10 col-xs-offset-1 ">
<div class="hero-unit row">
<div class="col-xs-12 ">
<h2 class="welcome">welcome</h2>
</div>
<div class="col-xs-12">
<div class="col-xs-4 pull-right">
<img class="img-responsive" src="/WebContent/img/both.png" alt="screenshots"/>
</div>
<p>some text here</p>
<p>imagine there is more text here</p>
<p>just, the most text ever.</p>
</div>
</div>
</div>
</div>
Bootply here: http://www.bootply.com/hANj4uFgb2

Bootstrap Center Scafolding

I'd have two "sections" in which I am using the bootstrap 3 scaffolding to style. I am having a hard time figuring out how I might have these maintain their column spacing while still be centered on the middle of the page. For example right now it is
<content><content> ---<space>---
and i want
---<space>--- <content><content> ---<space>---
Here is what i've got.
<div class=".container-fluid" id="aboutContent">
<div class="col-md-3">
<img src="../imgs/pic.jpg" alt="Joe Brunett" id="aboutPicture"/>
</div>
<div class="well col-md-4" id="desc">
<p> text<p>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3"></div>
</div>
</div>
Offsets can be used to center a div but remember that it'll work only for even columns
<div class="col-md-8 col-md-offset-2"></div>
You can even change the break-point by replacing
<div class="col-md-6 col-md-offset-3"></div>
with
<div class="col-sm-6 col-sm-offset-3"></div>