Text appears in two lines when browser width gets smaller - html

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/

Related

How to better display elements inside card?

i have a task where i should have information inside "card", it should be displayed like on my example(picture)
so here is my html
<div id="app">
<el-card shadow="always">
Dashboard
</el-card>
<el-card class="box-card">
<div slot="header">
<h2>Card name</h2>
<p>Challenge</p>
</div>
<div class="text item">
</div>
</el-card>
</div>
can you help me to place those "approved posts", "influences", "likes", "comments" like on picture?
let's say i don't have such big experience bud i think that i should use grid or table display...
can you show me some example or to show how could it be in my example?
Thank you!
i am using Vue.js and Element UI libruary
Basicaly you need to follow col's, if you're familiar with bootstrap. so 2 equal col does the job
ex:
<div class="row">
<div class="col-lg-12">
<div class="col-lg-6">
<label>Posts</label>
<label>545454</label>
</div>
<div class="col-lg-6">
<label>Influencer</label>
<label>56656</label>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="col-lg-6">
<label>Likes</label>
label>545454</label>
</div>
<div class="col-lg-6">
<label>Comments</label>
<label>56656</label>
</div>
</div>
</div>

bootstrap hidden-xs not working

I just found out about hidden-xs, hidden-sm etc, so am trying it out for the first time..
How come this doesn't hide the review div on any screen size?
<div class="row hidden-sm">
<div class="col-xs-12">
<result-reviews [result]='selectedResult?.result.result'></result-reviews>
</div>
</div>
Here is more of my code:
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col-lg-7">
<div class="row">
<div id="image-div" class="col-sm-5 col-lg-5">
<result-image [result]='selectedResult?.result.result'></result-image>
</div>
<div class="col-sm-7 col-lg-7">
<result-attributes [result]='selectedResult?.result.result'></result-attributes>
</div>
</div>
<div class="row hidden-sm">
<div class="col-xs-12">
<result-reviews [result]='selectedResult?.result.result'></result-reviews>
</div>
</div>
</div>
<div class="col-lg-5">
<div id="shops-section">
<div id="map" #map></div>
<ul>
<li *ngFor="let shop of selectedResult?.result.result.nearbyShops">
<div class="shop-details">
{{ shop.name }}
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
Which version of bootstrap are you using? In the bootstrap 4 alpha the hidden-xs classes (and sm, md, ...) have been replaced by hidden-xs-up or hidden-xs-down as explained here:
http://v4-alpha.getbootstrap.com/layout/responsive-utilities/
It works with d-none d-sm-block! Try this if you want to hide the division.
For reference, this is the link Getbootstrap Migration
How come this doesn't hide the review div on any screen size?
Read this part of the bootstrap documentation: http://getbootstrap.com/css/#responsive-utilities-classes
hidden-sm will only apply to sizes between 768 and 992px width.
Since bootstrap v.4.0 (stable)
All #screen- variables have been removed in v4.0.0. Use the media-breakpoint-up(), media-breakpoint-down(), or media-breakpoint-only() Sass mixins or the $grid-breakpoints Sass map instead.

bootstrap columns overlapping

I have an issue with bootstrap's grid layout. My columns are overlapping one another when I resize the screen to a smaller layout.
I'm not sure what the issue is.
Here is a picture of what is going on:
Here is my code
<div class='container-fluid'>
<div class="row"> <!-- 1 -->
<div class="col-sm-5 col-md-4">
<h1>JOHN SMITH</h1>
</div>
</div>
<div class='row'> <!-- 2 -->
<div class="col-sm-5 col-md-4">
<h2>VULCAN FLATBED</h2>
</div>
</div>
<div class="row"> <!-- 3 -->
<div class="col-sm-4 col-md-4 col-lg-4" style="background-color:yellow;">
<div class='row'>
<img src="vulcan.jpg" alt="vehicle image" width='391'/>
</div>
<div class='row'>
<button type='submit'>
<img src="book_now_button#2x.png" alt="book now">
</button>
</div>
</div>
<div class="col-sm-8 col-md-8 col-lg-8" style="background-color:pink;"> <!-- RIGHT SIDE -->
<div class='row'>
<h3>CAN HELP WITH</h3>
<p>LIFTING & YARD WORK</p>
</div>
<div class='row'>
<h3>AVAILABLE</h3>
<p>ALL WEEKENDS</p>
</div>
<div class='row'>
<h3>NOTE</h3>
<p>HI, MY NAME IS JOHN AND I HAVE A GREAT TRUCK FOR TRANSPORTING CARS,
WORK MATTERIAL, OR HEAVY OBJECTS. I HAVE A FULL TIME JOB SO I CAN
ONLY HELP YOU ON THE WEEKENDS. I LOVE WORKING WITH MY HANDS SO IF YOU
SOME HELP WITH LIFTING OR YARDWORK I AM YOUR GUY. BOOK NOW TO CONTACT
ME AND LET ME HELP YOU OUT.
</p>
</div>
</div>
</div> <!-- end 3 -->
<hr>
</div> <!-- end wrap -->
According to Bootstrap Docs, for each .row you need to have a .col-*-* as direct child but you don't have it in a few of them. Which cause the overflow.
Plus don't use the html tag width, it is deprecated. use class="img-responsive" from bootstrap to achieve max-width:100%
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class='container-fluid'>
<div class="row">
<!-- 1 -->
<div class="col-sm-5 col-md-4">
<h1>JOHN SMITH</h1>
</div>
</div>
<div class='row'>
<!-- 2 -->
<div class="col-sm-5 col-md-4">
<h2>VULCAN FLATBED</h2>
</div>
</div>
<div class="row">
<!-- 3 -->
<div class="col-sm-4 col-md-4 col-lg-4" style="background-color:yellow;">
<div class='row'>
<div class="col-xs-12">
<img class="img-responsive" src="//lorempixel.com/500/200" alt="vehicle image" />
</div>
</div>
<div class='row'>
<div class="col-xs-12">
<button type='submit'>
<img src="book_now_button#2x.png" alt="book now">
</button>
</div>
</div>
</div>
<div class="col-sm-8 col-md-8 col-lg-8" style="background-color:pink;">
<!-- RIGHT SIDE -->
<div class='row'>
<div class="col-xs-12">
<h3>CAN HELP WITH</h3>
<p>LIFTING & YARD WORK</p>
</div>
</div>
<div class='row'>
<div class="col-xs-12">
<h3>AVAILABLE</h3>
<p>ALL WEEKENDS</p>
</div>
</div>
<div class='row'>
<div class="col-xs-12">
<h3>NOTE</h3>
<p>HI, MY NAME IS JOHN AND I HAVE A GREAT TRUCK FOR TRANSPORTING CARS, WORK MATTERIAL, OR HEAVY OBJECTS. I HAVE A FULL TIME JOB SO I CAN ONLY HELP YOU ON THE WEEKENDS. I LOVE WORKING WITH MY HANDS SO IF YOU SOME HELP WITH LIFTING OR YARDWORK I
AM YOUR GUY. BOOK NOW TO CONTACT ME AND LET ME HELP YOU OUT.
</p>
</div>
</div>
</div>
I believe your problem is that you have many elements with the "row" class that don't have any columns in them. The hierarchy goes container > row > col. Without a column, there is no need for anything to be declared a row, and it affects the layout in unusual ways without them.
Another problem is your image. Remove the "width" attribute, and add the following class attribute: class="img-responsive". See the Images section of the bootstrap docs for details.
In my case, I was using box-sizing: content-box; for all my elements in css. That is why padding was creating problems with overall computed width of the elements. So, I changed it to box-sizing: border-box; from box-sizing: content-box;
Ref:
https://getbootstrap.com/docs/4.0/getting-started/introduction/#box-sizing

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%;
}

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>