I am using bootstrap grid to have the responsive layout.
But I am unable to remove gap between two columns.
my code is as follows:
<div class="contact-us-box">
<div class="container-fluid">
<div class="row">
<div class="col-lg-2 col-md-2">
</div>
<div class="col-lg-6 col-md-7 col-sm-8 col-xs-12 text-center">
<p class="contact-us-footer">Choose Share&Care as your development partner </p>
</div>
<div class="col-lg-4 col-md-3 col-sm-4 col-xs-12 text-center">
<a class="contact-us-link" href="../contact-us.php">
<i class="fa fa-envelope-o"></i> Contact Now!
</a>
</div>
</div>
</div>
</div>
my output is:
I want to remove the gap between partner and contact now button.
please help me is this regard.
My Solution
here is my solution:
<div class="contact-us-box">
<div class="container-fluid">
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-9 col-xs-12 contact-us-gap-p">
<p class="contact-us-footer">Choose Share&Care as your development partner </p>
</div>
<div class="col-lg-4 col-md-4 col-sm-3 col-xs-12 contact-us-gap-a">
<a class="contact-us-link" href="contact-us.php">
<i class="fa fa-envelope-o"></i> Contact Now!
</a>
</div>
</div>
</div>
</div>
here is my css file :
.contact-us-gap-p{
text-align: right;
}
.contact-us-gap-a{
text-align: left;
}
#media (max-width: 768px) {
.contact-us-gap-p{
text-align: center;
}
.contact-us-gap-a{
text-align: center;
}
}
This code is working fine for me.
Here I used css inline for semplicity, but using class is better. I simply aligned the text of the two div to reduce the gap between the two columns.
<div style="text-align: right;" class="col-lg-6 col-md-7 col-sm-8 col-xs-12 text-center">
...
</div>
<div style="text-align: left;" class="col-lg-4 col-md-3 col-sm-4 col-xs-12 text-center">
If you do not want this to apply in mobile version, insert this code into media query for screen only
....
Related
I have the following bootstrap-4 column structure:
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-4">A</div>
<div class="col-xs-6 col-sm-4">B</div>
<div class="col-xs-6 col-sm-4">C</div>
</div>
</div>
The expected column layout according to screen size is:
XS:
[ A ]
[B][C]
SM and up:
[A][B][C]
However, at XS each div takes the full width like this:
[A]
[B]
[C]
Check JSFiddle snippet here.
What could be wrong here?
col-xs-* simply does not exists on Bootstrap
The grid options are:
col-*
col-sm-*
col-md-*
col-lg-*
col-xl-*
Soucre: https://getbootstrap.com/docs/4.0/layout/grid/#grid-options
So probably what you wanted to use is col-*
.row {
background: #E2E2E2;
}
.card {
border: solid 1px #6c757d;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-12 col-sm-4 text-center">
<div class="card">
<div class="card-body">
A
</div>
</div>
</div>
<div class="col-6 col-sm-4 text-center">
<div class="card">
<div class="card-body">
B
</div>
</div>
</div>
<div class="col-6 col-sm-4 text-center">
<div class="card">
<div class="card-body">
C
</div>
</div>
</div>
</div>
</div>
You're using col-xs- but it doesn't exist in Bootstrap version 4.x.
So the small breakpoint is actually the first one defined mobile and up.
If you intend to have B & C to be half the size on mobile, I suggest to program it like this:
<div class="container">
<div class="row">
<div class="col-sm-4">
<div class="card text-center">
<div class="card-body">
A
</div>
</div>
</div>
<div class="col-6 col-sm-4">
<div class="card text-center">
<div class="card-body">
B
</div>
</div>
</div>
<div class="col-6 col-sm-4">
<div class="card text-center">
<div class="card-body">
C
</div>
</div>
</div>
</div>
</div>
If not, move the breakpoint of sm up to md.
Moving "div class row" one line below will solve your problem.
I've tested your code on "codepen.io", and works just fine. Maybe the "CDN" that "jsfiddle" uses is some version that does not render the classes in the appropriate manner. It is important whether you are using a "CDN" or you are downloading the files on you pc (.js, .css, etc.), that they support the Bootstap version you are using.
Be a hard one to explain so I hope that I will provide enough descriptive information. I have a header which takes advantage of the profile container function and also using the profile-stats with stats-col. Currently, it is laid out as the following but I would like to modify it so the lines are consistent and go straight down.
My code for that is the following:
.profile-container .profile-header .profile-stats .stats-col:not(:last-child) {
border-right: 1px solid #eeeeee;
}
.profile-container .profile-header .profile-stats .stats-col .stats-value {
display: block;
margin: 0 auto;
text-align: center;
font-size: 30px;
font-family: 'Open Sans', 'Segoe UI';
HTML
<div ng-hide="isNewSite">
<div class="row">
<div class="col-xs-12 col-md-12">
<div class="col-xs-6 col-md-6 text-align-left no-padding-left">
<h4>Site Entitlements View</h4>
</div>
<div class="pull-right">
<button class="btn btn-sky" ng-click="toggleButtonFunctionality()">
{{editButtonText}}
</button>
<button class="btn btn-darkorange" ng-click="handleDelete()" title="{{disableDeletionReason}}">
Delete Site
</button>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="profile-container">
<div class="profile-header row">
<div class="col-lg-2 col-md-4 col-sm-12 text-center">
<img src="assets/img/PICTURE.png" alt="" class="header-avatar"/>
</div>
<div class="col-lg-5 col-md-8 col-sm-12 profile-info">
<div class="header-fullname">{{targetEntity.siteName}}</div>
<span ng-bind-html="renderEntityState(targetEntity.status)"></span>
<div class="header-information" style="font-size:15px">
{{targetEntity.address1}}
<br>{{targetEntity.city}} </br>
{{targetEntity.postCode}}
<br>{{targetEntity.country}} </br>
</div>
</div>
<div class="col-lg-5 col-md-12 col-sm-12 col-xs-12 profile-stats">
<div class="row" >
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 stats-col" >
<div class="stats-value purple">{{serviceTotal}}</div>
<div class="stats-title">SERVICES</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 stats-col">
<div class="stats-value purple">{{siteSubjectsTotal}}</div>
<div class="stats-title">SUBJECTS</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 stats-col">
<div class="stats-value purple">
<a ui-sref="app.client-details({clientId:entity.clientIdId})"
ui-sref-active="active" class="purple">{{targetEntity.clientName}}
</a>
</div>
<div class="stats-title">CLIENT</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I do know that if I remove the .stats.-col then it does become consistent in the look but I still want the space between the values.
So I am wondering does anyone know what I could do? If you need further explanation I am happy to help.
How can I get the x positioned vertical middle when displaying on small devices (< 600px width)?
<div class="row">
<div class="col-sm-12">
<section class="panel panel-default panel-slider"><div class="panel-heading">
<h1 class="panel-title" style="font-size:18px">
Test with long description in title panel bla bla<a class="align-middle more pull-right" href="https://example.com" title="" data-toggle="tooltip" data-placement="right" data-original-title="more" ><i>x</i></a>
</h1>
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-8" style="margin-bottom: 10px;">
...
</div>
</div>
Currently it is:
Should be:
https://jsfiddle.net/9dtu4en1/
Thanks in advance!
Kind regards
Alex
I'd use flexbox on that h1 for a more fluid resizing, and remove align-middle & pull-right (to avoid floating which would make it's parent not consider child's height) from a:
External Fiddle to resize
Snippet:
h1 {
display: flex;
justify-content: space-between;
align-items: center;
}
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div class="col-sm-12">
<section class="panel panel-default panel-slider">
<div class="panel-heading">
<h1 class="panel-title" style="font-size:18px">Test with long description in title panel bla bla
<a class="more" href="https://example.com" title="" data-toggle="tooltip" data-placement="right" data-original-title="more"><i>x</i></a>
</h1>
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-8" style="margin-bottom: 10px;">
...
</div>
</div>
Using Bootstrap 3, I'm trying to center a image on its own row. Here is what I have, which responds well across display sizes:
<div class="row">
<div class="col-lg-2 col-lg-offset-5 col-md-2 col-md-offset-5 col-sm-4 col-sm-offset-4 col-xs-6 col-xs-offset-3 text-center">
<img src="img.jpg" class="img-responsive">
</div>
</div>
However, .img-responsive sets max-width: 100%. The image is too large on some displays. For example, I'd rather have col-lg-1 than col-lg-2.
Obviously, I could do col-lg-1 col-lg-offset-5 but the content will be off-center.
Is there an equivalent to col-lg-1 col-lg-offset-5.5, or some other method to center content in this scenario?
I would say no by default. But It can be possible with Bootstrap customize then you can define your custom responsive grid column with #grid-columns. You can specify 16.
<div class="row">
<div class="col-lg-2 col-lg-offset-7 text-center">
<img src="img.jpg" class="img-responsive">
</div>
</div>
Or you can just style your image to be smaller width.
<div class="row">
<div class="col-lg-2 col-lg-offset-5 col-md-2 col-md-offset-5 col-sm-4 col-sm-offset-4 col-xs-6 col-xs-offset-3 text-center">
<img src="img.jpg" class="img-resize img-responsive">
</div>
</div>
<style type="text/css">
.img-resize {
width: 200px;
}
</style>
How do I make my pictures be aligned in the center when the screen shrinks to small to keep them side by side? I tried using columns, but it has a weird offset and it won't scoot to the side or align in a straight column when needed.
Here is my code:
<h2 class="text-center h2">Recent Projects</h2>
</div>
<div class="pics col-md-4 col-md-offset-2 col-xs-10 col-xs-offset-1">
<a href="350_project.html">
<img src="images/IMG_2579.JPG" width="450" height="350">
</a>
<h3 class="text-center">350 Project</h3>
</div>
<div class="pics col-md-6 col-md-offset-1 col-xs-10 col-xs-offset-1">
<a href="silk_screening.html">
<img src="images/IMG_0978.JPG" width="450" height="350">
</a>
<h3 class="text-center">Silk Screening</h3>
</div>
<div class="pics col-md-4 col-md-offset-2 col-xs-10 col-xs-offset-1">
<a href="compost.html">
<img src="images/IMG_7793.JPG" width="450" height="350">
</a>
<h3 class="text-center">Food Feud</h3>
</div>
<div class="pics col-md-6 col-md-offset-1 col-xs-10 col-xs-offset-1">
<a href="terracycle.html">
<img src="images/Official_TerraCycle_Logo.png" width="450" height="350">
</a>
<h3 class="text-center">TerraCycle</h3>
</div>
You could use #media queries, making your div having something like "margin: auto" at a certain screen size or with a global parent div with "text-align:center".
Don't forget bootstrap grid item have a default "float:left" attribut, maybe you'll have to change it with #media queries.
I used it in my last project. I don't know it my objectives are compatibles with yours but it could help you.
<div class="container_losange container_losange_mission col-lg-4 col-md-4 col-sm-4 col-xs-8"> //content </div>
<div class="container_losange container_losange_mission float-right col-lg-4 col-md-4 col-sm-4 col-xs-8"> //content </div>
<div class="container_losange container_losange_mission col-lg-4 col-md-4 col-sm-4 col-xs-8"> //content </div>
<div class="clear"></div>
<div class="container_losange container_losange_mission float_none float-right col-lg-4 col-md-4 col-sm-4 col-xs-8"> //content </div>
<div class="container_losange container_losange_mission float_none float-left col-lg-4 col-md-4 col-sm-4 col-xs-8"> //content </div>
Then here I have 3 + 2 divs. The 2 last divs are center in the page because I make some modification :
.section_mission {
text-align: center;
.container_losange_mission {
display: inline-block;
&.float_none {
float: none;
}
}
float-right and float-left are just here for the specific design of the mobile view. (to have a "staggered" structure)
The clear div doesn't seems to be needed, I didn't remember why I used it.
/* Extra small devices (Phones (<768px)) */
#media(max-width:767px){
.section_mission {
.container_losange_mission.float-right { float: right !important; }
.container_losange_mission.float-left { float: left !important; }
}
}
I don't know if my explications are usefull for you because I'm not sure it'll works with random number of elements..
If not, have a look on the CSS3 new functionnality FLEX:
http://the-echoplex.net/flexyboxes/
http://www.alsacreations.com/tuto/lire/1493-css3-flexbox-layout-module.html
Could be usefull on this type of problem