I just built a new site from scratch using Bootstrap 4. I created a fluid container, then into that I inserted a Grid Row with 8 columns, and into each of these 8 columns I inserted a card with images.
Everything looked fine until I realized that it isn't responsive. In fact at xl the cards display at 4 in a row, but at lg the cards all stack vertically as if viewing on a phone.
Try as I might, I can't get the cards to be responsive no matter how much I play with the col classes.
Can someone help me to get this thing responsive? Basically I'd like the cards 4 across at xl (that's what they're doing now), 3 across at lg, and 2 across at md, sm, and xs. Again, right now it's displaying at 4 across at xl and only 1 across (stacking vertically) at all other sizes.
This is my first time here and hopefully after I type this I can include some code. Much appreciated.
Code example:
<div class="container-fluid">
<!--Image Grid-->
<div class="row">
<!--Real people Reel-->
<div class="col-xl-3">
<div class="card col-md-4 col-xl-12"> <img class="card-img-top img-fluid" src="images/university_hospital_network.jpg" alt="Real people Reel"> </div>
<div class="card-body">
<h5 class="card-title">Real People Reel</h5>
<p class="card-text text-open-sans">Your greatest and most credible asset.</p>
<br>
<br>
</div>
</div>
<!--End Real People Reel-->
<!--University Hospital Newark-->
<div class="col-xl-3">
<div class="card col-md-4 col-xl-12"> <img class="card-img-top img-fluid" src="images/surgeons.jpg" alt="Real people Reel"> </div>
<div class="card-body">
<h5 class="card-title">University Hospital Newark</h5>
<p class="text-open-sans">Medical accuracy... expert compliance, clearances and licensing expertise.</p>
<br>
<br>
</div>
</div>
<!--End University Hospital Newark-->
I think each "item" in a row, insert responsive class to there like that.
<div class="container-fluid">
<!--Image Grid-->
<div class="row">
<!--Real people Reel-->
<div class="col-xl-3 col-lg-4 col-md-6"> <!-- add new class here -->
<div class="card"> <!-- remove class here -->
<img class="card-img-top img-fluid" src="images/university_hospital_network.jpg" alt="Real people Reel"> </div>
<div class="card-body">
<h5 class="card-title">Real People Reel</h5>
<p class="card-text text-open-sans">Your greatest and most credible asset.</p>
</div>
</div>
<!--End Real People Reel-->
<!--University Hospital Newark-->
<div class="col-xl-3 col-lg-4 col-md-6">
<div class="card">
<img class="card-img-top img-fluid" src="images/surgeons.jpg" alt="Real people Reel"> </div>
<div class="card-body">
<h5 class="card-title">University Hospital Newark</h5>
<p class="text-open-sans">Medical accuracy... expert compliance, clearances and licensing expertise.</p>
</div>
</div>
</div>
<!--End University Hospital Newark-->
</div>
</div>
By the way, visit W3School for more information about Bootstrap 4 grid system
So I hope it can help you.
Related
Media Query for bootstrap 4, unresponsive. I have two cards side by side in a section. When I get down to 576px I want to be able to display the cards side by side.
I've tried setting the parent containers to float: none and float: left. Also tried incorporating display: block on the Query.
<section id="recipeList">
<div class="recipeName"></div>
<div class="row">
<div class="col-sm-6">
<div class="card image-container">
<img class="card-img-top" src="./assets/images/Dish.svg"
alt="places restaurants png">
<div class="card-body ingredients" id="foodImage">
<p class="card-text"></p>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="card ingredients-card">
<img class="card-img-top"
src="./assets/images/Contents.svg" alt="places restaurants png">
<div class="card-body overflow-auto">
<h2 class="card-title"></h2>
<p class="card-text overflow-auto" id="facts"></p>
</div>
</div>
</div>
</div>
</section>
I would love for the two bootstrap cards to be responsive rather than just squeezing downwards
I got 3 news articles, each with its own image below. Problem is the text are quotes and varies in sizes. So they do not align, added height px which works for the Desktop version but when it goes to the mobile version the height is still obviously there and make a big weird gap between the articles.
<div style="padding-top:50px;" class="container">
<div class="card-deck">
<div class="col-sm-4">
<div class="card" style="margin:0!important;border:none;">
<div class="card-body">
<p style="text-align:center" class="card-text">"With an impressive and evergrowing number of studies finding CBD to be a powerful antioxidant and anti-inflammatory among many other properties, it is now being used to treat pain, anxiety, spasms, and much more"</p>
</div>
<img class="card-img-top" src="img\quote_pic1.png" alt="Daily Mail" style="width:50%;height:40px;margin:auto;">
</div>
</div>
<div class="col-sm-4">
<div class="card" style="margin:0!important;border:none;">
<div class="card-body">
<p style="text-align:center" class="card-text">“I think there is a legitimate medicine here,” he said. “We’re talking about something that could really help people.” Neurosurgeon Dr. Sanjay Gupta</p>
</div>
<img class="card-img-top" src="img\quote_pic2.png" alt="World Health Organization" style="width:50%;height:40px;margin:auto;">
</div>
</div>
<div class="col-sm-4">
<div class="card" style="margin:0!important;border:none;">
<div class="card-body">
<p style="text-align:center" class="card-text">Dr. Esther Blessing, an associate professor of psychiatry at New York University says current evidence suggests that CBD shows promise for helping to treat everything from Anxiety to PTSD</p>
</div>
<img class="card-img-top" src="img\quote_pic3.png" alt="The Washington Post" style="width:80%;height:40px;margin:auto;">
</div>
</div>
</div>
</div>
Mobile Version Big Gaps
I recommend removing the columns. You're in a card-deck, and you can set how many cards show per row/column in your CSS.
Additionally, I removed the margin:0!important;border:none; as 1) inline isn't great, and 2) this can be taken care of with built-in Bootstrap styles m-0 and border-0. Also text-center removes the need for inline centering on your <p> tags.
Here is the result... (images added so I can see how actual images appear)
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<div class="container pt-5">
<div class="card-deck">
<div class="card m-0 border-0">
<div class="card-body">
<p class="card-text tex-center">"With an impressive and evergrowing number of studies finding CBD to be a powerful antioxidant and anti-inflammatory among many other properties, it is now being used to treat pain, anxiety, spasms, and much more"</p>
</div>
<img class="card-img-top mx-auto" src="https://dummyimage.com/100x50/fff/000&text=LOGO" style="max-width: 40%;" alt="Daily Mail">
</div>
<div class="card m-0 border-0">
<div class="card-body">
<p class="card-text tex-center">“I think there is a legitimate medicine here,” he said. “We’re talking about something that could really help people.” Neurosurgeon Dr. Sanjay Gupta</p>
</div>
<img class="card-img-top mx-auto" src="https://dummyimage.com/100x50/fff/000&text=LOGO" style="max-width: 40%;" alt="World Health Organization">
</div>
<div class="card m-0 border-0">
<div class="card-body">
<p class="card-text tex-center">Dr. Esther Blessing, an associate professor of psychiatry at New York University says current evidence suggests that CBD shows promise for helping to treat everything from Anxiety to PTSD</p>
</div>
<img class="card-img-top mx-auto" src="https://dummyimage.com/100x50/fff/000&text=LOGO" style="max-width: 40%;" alt="The Washington Post">
</div>
</div>
</div>
Hi I have this portion of my website Link here to broken portion and for some reason, the bottom of one of my sections is cut off. If I add a different margin or padding to the main class I just get white area added and the bootstrap card still can't be read. Any ideas?
Picture:
HTML Code:
<div class="main">
<div class="page-header" id="Services" style="background-image: url('./assets/img/background-grassfade.png'); background-color:#fff;">
<div class="filter"></div>
<div class="container-fluid">
<div class="motto">
<div class="row">
<div class="col-md-8 offset-md-2 text-center">
<div class="space-top"></div>
<h2 class="title">Services</h2>
</div>
<div class="container">
<div class="space-top"></div>
<div class="card" data-background="color" data-color="blue">
<div class="card-body text-center d-flex flex-column">
<div class="row">
<div class="col-md-4 align-self-center vcenter">
<div class="card-icon">
<i class="far fa-car-mechanic"></i>
</div>
</div>
<div class="col-md-8 venter">
<h4 class="card-title">Roadside Assistance</h4>
<p class="card-description">Jumpstarting, Tire changes, Fuel and fluid dilvery, Extrication/Pullout. </p>
<p class="card-footer align-self-end mt-auto">
<b>*Delivery of non-alcoholic refreshments upon request for an additional charge.</b>
</p>
</div>
</div>
</div>
</div>
<div class="card" data-background="color" data-color="green">
<div class="card-body text-center d-flex flex-column">
<div class="row">
<div class="col-md-4 align-self-center vcenter">
<div class="card-icon">
<i class="far fa-people-carry"></i>
</div>
</div>
<div class="col-md-8 venter">
<h4 class="card-title">Hauling</h4>
<p class="card-description">Including Rock, Sand, Mulch, Dirt, Feed, Hay, Plants, Trees, Firewood, Applicances, etc. Moving Services, Junk/debris cleanup, small buisness deliveries, post garage sale deliveries. </p>
<p class="card-footer align-self-end mt-auto">
<b>*Loading, transport and unloading covered.</b>
</p>
</div>
</div>
</div>
</div>
<div class="card" data-background="color" data-color="orange">
<div class="card-body text-center d-flex flex-column">
<div class="row">
<div class="col-md-4 align-self-center vcenter">
<div class="card-icon">
<i class="far fa-home"></i>
</div>
</div>
<div class="col-md-8 venter">
<h4 class="card-title">Residential Home Exterior</h4>
<p class="card-description">Including Snow removal (driveways and sidewalks only currently) , Lawn care, Tree and Bush pruning/trimming, Stump removal, Leaf removal, Gutter cleaning, yard debris and junk removal, Landscaping, Power washing (Homes, Concrete, vehicles),
Window washing, Light construction demolition, Fence demolition. </p>
</div>
</div>
</div>
</div>
<div class="card" data-background="color" data-color="brown">
<div class="card-body text-center d-flex flex-column">
<div class="row">
<div class="col-md-4 align-self-center vcenter">
<div class="card-icon">
<i class="far fa-toolbox"></i>
</div>
</div>
<div class="col-md-8 venter">
<h4 class="card-title">Residential Home Interior</h4>
<p class="card-description">Including Window washing, Batt insulation installation and removal, Drywall installation and removal, Indoor painting, Mild carpet and flooring cleanings, Maid services, Rearranging furniture, Drain cleaning, General home maintenance,
Baby proofing. </p>
</div>
</div>
</div>
</div>
<div class="card" data-background="color" data-color="yellow">
<div class="card-body text-center d-flex flex-column">
<div class="row">
<div class="col-md-4 align-self-center vcenter">
<div class="card-icon">
<i class="far fa-shopping-basket"></i>
</div>
</div>
<div class="col-md-8 venter">
<h4 class="card-title">Miscellaneous Services</h4>
<p class="card-description">Construction site clean up, Storm debris removal, Grocery pick up and delivery, vehicle hail dent repair, vehicle washing and detailing (we drive to you!), Dog walking, pet feces removal (outdoors only), Holiday lights/decoration installation.
Looking for something not on this list? Call for pricing/availability! </p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
The template is from Creative Tim: Creative Tim's Website and the CSS used is the included CSS with minimal changes and nothing that should touch any of this.
What I've tried:
Adding margin/margin-bottom to the main, container-fluid, motto and row as well as padding/padding-bottom
I have tried to change the margin-top of the section below it.
I have tried to add space using both <br /> and the provided space-top class.
I can include more of the HTML for the section below if needed. I included a link to the site currently, you should be able to use inspect element to sift around with grabbing CSS but I can include CSS if need be. I couldn't find anywhere that said I could not post a link to my page directly but if I cannot please let me know and I will remove it.
The page-header element inside paper-kit.css has a max-height:
.page-header {
max-height: 999px;
}
You content must be taller than that max-height (not sure why one would set a max-height on a div in a vertical layout but oh well). Comment it out in the web dev tools and all looks fine.
there is a max height of 999px in the class page-header, which is limiting the height remove it
This question already has an answer here:
Bootstrap 3 - Aligning column height
(1 answer)
Closed 6 years ago.
Beginner here, I am building a one page bootstrap site, I have divided the site into sections, i have already added 1st image as the background in section one.
I have tried using the columns but no vial.
I cant get the two images side by side like shown in the prototype (http://imgur.com/a/MJQ2w).
I want the page layout to be like this with no margins but i am unable to do this with bootstrap. Please help me with your expertise.
<header style="background-image: url('static/assets/home-bg.jpg');">
<div class="intro-content">
<div class="brand-name">Learning & Experience</div>
<hr class="colored">
<div class="brand-name-subtext">Lorem Ipsum Dolor Init
</div>
</div>
<div class="scroll-down">
<a class="btn page-scroll" href="#about"><i class="fa fa-angle-down fa-fw"></i></a>
</div>
</header>
<section id="about">
<div class="container-fluid">
<div class="row row-no-gutter">
<div class="col-md-6 img-responsive">
<img src="static/assets/training.png">
</div>
<div class="col-md-6 img-responsive">
<img src="static/assets/recruit.png" >
</div>
</div>
</div>
<div>
Check my example here, Without removes any padding provide by bootstrap
HTML
<section class="values">
<div class="col-md-4 box text-white box blues">
<div class="box-home">
<h4>our values</h4>
<p>At MOCAZ PRIME, with the expertise of experienced traders, we join in giving the best advice and knowledge to individuals to ensure their financial goals can be achieved in any market conditions.</p>
<div class="icon-text">
<p>01.</p>
</div>
</div>
</div>
<div class="col-md-4 text-white box bg-city blacks">
<div class="box-home">
<h4>our philipsophy</h4>
<p>It is our ambition to keep up challenges of a dynamic and changing market. Consequently it is necessary to flexibly bring new techniques which meet the needs of our customers. This all predetermines us to achieve a leading position in the global financial advisory services.</p>
<div class="icon-text">
<p>02.</p>
</div>
</div>
</div>
<div class="col-md-4 text-white box blacks">
<div class="box-home">
<h4>our mission</h4>
<p>Our mission is to facilitate a world-class foreign exchange, metal and contracts for difference trading environment. We're dedicated to providing industry-leading technology to the international trading community and we strive to deliver educational tools and resources that enable traders to further develop their trading skills.</p>
<div class="icon-text">
<p>03.</p>
</div>
</div>
</div>
</section>
DEMO
Replace your code
<div class="col-md-6 img-responsive">
<img src="static/assets/training.png">
</div>
<div class="col-md-6 img-responsive">
<img src="static/assets/recruit.png" >
</div>
With following line of code
<div class="col-md-6">
<img src="static/assets/training.png" class=" img-responsive" />
</div>
<div class="col-md-6">
<img src="static/assets/recruit.png" class=" img-responsive" />
</div>
Fixed the issue, Thanks guys.
<section id="about">
<div class="container-fluid">
<div class="row" id="port2-second-row">
<div class="col-xs-6 imgcont" id="port2-first-col">
<img src="static/assets/training.png" alt="training" />
</div> <!-- end col-sm-6 -->
<div class="col-xs-6 imgcont" id="port2-second-col">
<img src="static/assets/recruit.png" alt="recruit" />
</div> <!-- end col-sm-6 -->
</div> <!-- end port-second-row -->
CSS :
img {
width: 100%;
height: 100%;}
.imgcont {
padding: 0px;
I have a web page here where I use Bootstrap grid system. It should display three items per column but if you scroll down to like row 3/4 the items start to be misaligned. I noticed that if only one item is slightly longer than the component below, the whole grid becomes quite a mess afterwards.
Here is code for one item in the whole grid system:
<div class="col-sm-12 col-xs-12 col-md-6 col-lg-4">
<h4 align="center"><strong>Name</strong></h4>
<div class="row" align="center">
<div class="image-cropper">
<!... personal image...>
</div>
<div class="center-justified">
<!.. sth sth blah blah..>
</div>
</div>
</div>
Does anyone has any idea how this can be fixed?
EDIT: What I am trying to achieve is to display every three columns per row on the large screen and then when it shrinks it should only display every two columns per row on medium screen and full row for small screen.
At the moment, if I wrap a container/row around every three columns, when I resize it to medium screen size (having only two items per row) there will be a white gap when the class switches from .col-lg-4 to .col-md-6. And I want to get rid of that white gap.
For every two column put them in containers like such this will give the result your looking for :
<div class="container">
<div class="col-md-6">
Your code here...
</div>
<div class="col-md-6">
Your code here...
</div>
</div>
Then just do this for every two people you write about on your website. Hope this helped.
please try this below code
<div class="container">
<!--Row 1-->
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
<h4 align="center"><strong>Martin Sandve Alnæs</strong></h4>
<div class="row" align="center">
<div class="image-cropper">
<div class="mugshot2" alt='Martin Sandve Alnæs' style='background: url(/_static/images/mugshots/alnaes.jpg) no-repeat 50% 50%' ></div>
</div>
<div class="center-justified">
<p>Martin is a postdoctoral fellow at Simula Research Laboratory.
</p>
<p>He has been involved with the FEniCS Project since 2006,
is the main developer of UFL and SFC, and one of the
developers of UFC, Instant, SyFi and DOLFIN.</p>
<p>You can view all Martin’s contributions on <a
href="https://bitbucket.org/martinal">his Bitbucket
page.</a></p>
</div>
</div>
</div>
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
<h4 align="center"><strong>Jan Blechta</strong></h4>
<div class="row" align="center">
<div class="image-cropper">
<div class="mugshot2" alt='Jan Blechta' style='background: url(/_static/images/mugshots/blechta.jpg) no-repeat 50% 50%' ></div>
</div>
</div>
<div class="center-justified">
<p>
Jan is a PhD. student of
Mathematical Modelling
at the
Charles University in Prague.
</p>
<p>
He has been involved with the FEniCS project since 2013 and is a
developer and maintainer of DOLFIN and Instant.
</p>
<p>You can view all Jan’s contributions on <a
href="https://bitbucket.org/blechta">his Bitbucket
page.</a></p>
</div>
</div>
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
<h4 align="center"><strong>Johan Hake</strong></h4>
<div class="row" align="center">
<div class="image-cropper">
<div class="mugshot2" alt='Johan Hake' style='background: url(/_static/images/mugshots/hake.jpg) no-repeat 50% 50%' ></div>
</div>
</div>
<div class="center-justified">
<p>Johan is a postdoctoral fellow at Simula Research Laboratory.
</p>
<p>He has been involved with the FEniCS Project since 2007,
is a maintainer of the Python interface of DOLFIN, and is
a developer of Instant, UFC and FFC.</p>
<p>You can view all Johans’s contributions on <a
href="https://bitbucket.org/johanhake">his Bitbucket
page.</a></p>
</div>
</div>
<div class="clearfix visible-*-block"></div>
<!--End of Row 1-->
<!--Row 2 -->
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
<h4 align="center"><strong>Johan Hoffman</strong></h4>
<div class="row" align="center">
<div class="image-cropper">
<div class="mugshot2" alt='Johan Hoffman' style='background: url(/_static/images/mugshots/hoffman.jpg) no-repeat 50% 50%' ></div>
</div>
</div>
<div class="center-justified">
<p>Johan is a professor at the KTH Royal Institute of Technology.
</p>
<p>He has been involved with the FEniCS Project since 2003
and is a developer of DOLFIN and Unicorn.</p>
</div>
</div>
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
<h4 align="center"><strong>Johan Jansson</strong></h4>
<div class="row" align="center">
<div class="image-cropper">
<div class="mugshot2" alt='Johan Jansson' style='background: url(/_static/images/mugshots/jansson.jpg) no-repeat 50% 50%' ></div>
</div>
</div>
<div class="center-justified">
<p>Johan is a senior researcher at the <a href="http://www.kth.se/">KTH Royal Institute of
Technology</a>.</p>
<p>He has been involved with the FEniCS Project since 2004
and is a developer of DOLFIN and Unicorn.</p>
</div>
</div>
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
<h4 align="center"><strong>Benjamin Kehlet</strong></h4>
<div class="row" align="center">
<div class="image-cropper">
<div class="mugshot2" alt='Benjamin Kehlet' style='background: url(/_static/images/mugshots/kehlet.jpg) no-repeat 50% 50%' ></div>
</div>
</div>
<div class="center-justified">
<p>Benjamin is a Ph.D. student at
Simula Research Laboratory and the
University of Oslo.
</p>
<p>He has been involved with the FEniCS Project since 2011
and is the primary developer of msrh, the FEniCS meshing component.
</p>
<p>You can view all Benjamin’s contributions on <a
href="https://bitbucket.org/kehlet">his Bitbucket
page.</a></p>
</div>
</div>