Bootstrap 5 Gutters - How To Space Between Row Items In Bootstrap Grid - html

Hi i am using bootstrap 5 and using the grid functionality. I have divided my layout into 2 rows.
One row had text and image and other has two images.
It is showing totally fine in PC but with mobile view all the images does not have any spacing between them and it is looking bad.
I tried using gutters but it did not work out i dont know why.
Kindly Help. Here is the code
<div class="container">
<div class="row ">
<div class="col-lg-6">
<ul>
<li>The GATE course of Digcademy has been designed by experts who have vast experience of competitive examinations.</li>
<li>The GATE course is a three-tier approach to make the students more confident about their preparation.</li>
<li>The course is supported by topicwise videos so that there is no scope of doubt about the topic in the minds of students.</li>
<li>It covers theoretical concepts along with lot of topic wise examples. The examples given in the text are strictly from previous year GATE questions so that students can know the types of questions asked in GATE from that particular topic.</li>
<li>The practice questions at the end of each chapter cover all questions from GATE which appeared in EE, EC and IN branches from 1991 to till date for vide coverage of concepts.</li>
<li>The course includes topic wise practice test. These tests would help the students to know their performance after learning the concepts of each chapter.</li>
</ul>
</div>
<div class="col-lg-6">
<img src="images/electrical eng-1.jpg" alt="" style="width: 100%; height: auto">
</div>
</div>
</div>
<div class="container px-4">
<div class="row gy-5">
<div class="col-lg-6">
<img src="images/elect & comm eng-1.jpg" alt="" style="width: 100%; height: auto; position: relative">
</div>
<div class="col-lg-6">
<img src="images/instrumentation eng-1.jpg" alt="" style="width: 100%; height: auto">
</div>
</div>
</div>

You can put margin or padding at the bottom of each of your col divs. Since you’re using col-lg-6, for screen sizes less than lg, the columns will go full width. Adding bottom margin will give you a space. If you don’t want the space on lg screens, then you can use something like mb-3 mb-lg-0 to not have a margin on larger screens.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.1/dist/js/bootstrap.bundle.min.js"></script>
<div class="container">
<div class="row ">
<div class="col-lg-6">
<ul>
<li>The GATE course of Digcademy has been designed by experts who have vast experience of competitive examinations.</li>
<li>The GATE course is a three-tier approach to make the students more confident about their preparation.</li>
<li>The course is supported by topicwise videos so that there is no scope of doubt about the topic in the minds of students.</li>
<li>It covers theoretical concepts along with lot of topic wise examples. The examples given in the text are strictly from previous year GATE questions so that students can know the types of questions asked in GATE from that particular topic.</li>
<li>The practice questions at the end of each chapter cover all questions from GATE which appeared in EE, EC and IN branches from 1991 to till date for vide coverage of concepts.</li>
<li>The course includes topic wise practice test. These tests would help the students to know their performance after learning the concepts of each chapter.</li>
</ul>
</div>
<div class="col-lg-6 mb-3 mb-lg-0">
<img src="https://via.placeholder.com/480x360.png" alt="" style="width: 100%; height: auto">
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-6 mb-3 mb-lg-0">
<img src="https://via.placeholder.com/480x360.png" alt="" style="width: 100%; height: auto; position: relative">
</div>
<div class="col-lg-6 mb-3 mb-lg-0">
<img src="https://via.placeholder.com/480x360.png" alt="" style="width: 100%; height: auto">
</div>
</div>
</div>

I am not sure what you really want with this question. So you have "2 answers here"
if you need spacing directly around content use padding. If you want to have it "outside" the box, use margin.
Be aware, you using col-lg-6 (lg is only for window >= 992px, so not mobile)
Bootstrap know "col-6", "col-sm-6", "col-md-6", "col-lg-6", "col-xl-6", "col-xxl-6""
If you want same everywhere use "col-6". This is difference are because of "e.g. in desktop you want content in 2 columns - "col-xxl-6", but if you want in smaller screen only one (because you would have content too small) you use class like "col-12 col-lg-6" So in the smaller you will have 1 column, in bigger 2 :) tadaaa
E.g. below - green is padding, orange is margin

Related

Alignment issues in Bootstrap Containers

I'm currently building my first website in bootstrap 4, and I have some general questions to either which I can't find a good response to or want to know how to handle something... Here it goes:
Is it common to use multiple container styles throughout a website? I mean is it perfectly okay to have a 'container'in one place and 'container-fluid' elsewhere?
Additionally, I created something very small to see how things would work out. Boostrap provides a class called 'text-md-right' and from what I can tell it should right align the text. Let me show my sample code. Why is the text in my 'bg-success' not right-aligning?
<div class="container-fluid">
<div class="row">
<div class="col-md-3" style="min-height: 0.5rem; background-color: #FBB040"></div>
<div class="col-md-3" style="min-height: 0.5rem; background-color: #939598"> </div>
<div class="col-md-3" style="min-height: 0.5rem; background-color: #D1D3D4"> </div>
<div class="col-md-3" style="min-height: 0.5rem; background-color: #28AB9E"> </div>
</div>
<div id="outter-div" class="row">
<div id="inner-div-1-logo" class="col-md-3 test"><img src="images/logo.png" class="mx-auto d-block" alt="helloworld" style="width:200px"></div>
<div id="inner-div-1" class="col-md-8">
<div class="row contact-bar text-md-right bg-success"> hello world -- needs to be right-aligned</div>
<!--<div id="contact-bar" class="row bg-success contact-bar"> Call Us # (888) 888-8888 | info#email.com | Customer Portal </div> -->
<div id="nav-bar" class="row nav-bar bg-primary"> nav-bar </div>
</div>
</div>
</div>
I'd love hear some feedback on the approach I am taking to building this based on the code above. Am I headed in the correct direction here? Anything you would do different?
Thank you.
Please use below link to read about Grid System Rules.
Visit https://www.w3schools.com/bootstrap/bootstrap_grid_system.asp
After reading the rules you can get started with building your own Html pages using examples given in below link
https://getbootstrap.com/docs/4.0/examples/
Is it common to use multiple container styles throughout a website? I mean is it perfectly okay to have a 'container'in one place and 'container-fluid' elsewhere?
It depends on you. You can use .container and .container-fluid according to your needs. But you can not use in the order shown .container > .row > .column > .container-fluid.
Additionally, I created something very small to see how things would work out. Boostrap provides a class called 'text-md-right' and from what I can tell it should right-align the text. Let me show my sample code. Why is the text in my 'bg-success' not right-aligning?
Yes it'll be aligning right on medium devices only. If you want it for other devices just use .text-right
For reference go through this link https://getbootstrap.com/docs/4.0/layout/grid/

Layout for displaying text and buttons next to a picture

I want to acomplish something like this:
And so far after hours of learning bootstrap and playing with the grid system I managed to do this:
Code that I use:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-body">
<div class="row-fluid">
<div class="col-md-4">
<img class="img-responsive" src="https://images-na.ssl-images-amazon.com/images/M/MV5BMTUxMDc1OTAzM15BMl5BanBnXkFtZTgwOTMwOTMyMDI#._V1_SY1000_CR0,0,674,1000_AL_.jpg" style="width: 130px; height: 200px">
</div>
<div class="col-md-8">
<div class="row">
<div class="text-title">Logan 2017</div>
<p>
Set in the future, Logan and Professor Charles Xavier must cope with the loss of the X-Men when a corporation lead by Nathaniel Essex is bent on destroying the world. With Logan's healing ...
</p>
</div>
<div class="row">
<button class="btn btn-warning btn-bold-text">IMDb</button>
<button class="btn btn-danger pull-right"><span class="glyphicon glyphicon-remove"></span></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
As you can see, I want to be able to maximize the picture to the size of the panel, make buttons stick to bottom and fix the margin of the text.
Can someone help me ? Thanks!
I don't need anyone to do the code for me, just tell me what should I be looking for. Is there any spacing between columns in bootstrap ? I tried playing with margins and paddings but no chance of acomplishing what I want.
https://jsfiddle.net/0jv537r0/1/
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="well" style="position: relative; background: #fff;">
<div class="row">
<div class="col-xs-4">
<img class="img-responsive" src="https://images-na.ssl-images-amazon.com/images/M/MV5BMTUxMDc1OTAzM15BMl5BanBnXkFtZTgwOTMwOTMyMDI#._V1_SY1000_CR0,0,674,1000_AL_.jpg">
</div>
<div class="col-xs-8">
<div class="text-title">Logan 2017</div>
<p>
Set in the future, Logan and Professor Charles Xavier must cope with the loss of the X-Men when a corporation lead by Nathaniel Essex is bent on destroying the world. With Logan's healing ...
</p>
</div>
</div>
<button class="btn btn-warning btn-bold-text" style="position: absolute; bottom: 20px; left: 33.33333333%;">IMDb</button>
<button class="btn btn-danger pull-right" style="position: absolute; bottom: 20px; right: 20px;"><span class="glyphicon glyphicon-remove"></span></button>
</div>
</div>
</div>
</div>
So, I changed it to a well instead of a panel since you wern't actually using any of the panel elements other than the border. My answer isn't 100% full proof, you'd want to bring the styles not inline and add specifics for different screen widths, but in a nutshell at least you can see what I did to accomplish your goal. You could also use flexbox and then keep the buttons inside the col-xs-8 because with felxbox you could make the height of the col-xs-8 element match the height of the image.
Your "problem" is a commong one. Placing elements at the bottom of a parent element. There is generally not an out of the box solution to accomplish this. You must use position absolute. This position elements based on their closest non static parent. You could do this on the col-xs-8 element but because it's height won't match that of the image, that won't work you need to move the buttons outside the column. (Columns by default in Bootstrap have a non static position).
Now there are countless ways to accomplish what you wanted I just chose the route closet to what you had. I might suggest the media object (http://getbootstrap.com/components/#media) native to bootstrap. Wrap the media element in a wrapper with a border and you should be close to what you want, but really, media, panel, wells they are all similar. That is why in Bootstrap 4 they have all been removed in favor of cards. You might be better off going with BS4 as well. It's getting closer and closer to release and I have a site fully done with the current alpha and it's pretty solid. We're about to push the project to production too.

I need to center 3 <div> on the webpage

I need to fix 3 <div>s in the center of my webpage. I tried to use margin: 0 auto; but it doesn't work, even using Bootstrap's grid. It's complicated because whatever I'll do the 3 <div>s don't fix exactly in the middle. It most to goes 3 buttons, and every button has a paragraph below.
<section class="contenedor">
<nav>
<ul><div class="contenedor">
<li class="col-md-3"><img src="imagenes/icono-1.png" alt="responsive" class="center-block">
<p class="boton-textT">
RESPONSIVE</p>
<p class="boton-textT">WEB DESIGN</p>
<p class="boton-text col-md-12 ">
We create scalable Internet services.
The architecture of the content and
presentation is adapted to the screen
size and device type. We create
Responsive Web Design.
</p></li>
<li class="boton2 col-md-3"><img src="imagenes/icono-2.png" alt="mobile" class="center-block">
<p class="boton-textT">
MOBILE</p>
<p class="boton-textT">APPLICATIONS
</p>
<p class="boton-text col-md-12">
We design the user interfaces
of mobile applications. We know the
iPhone users' needs as well as Metro
system's requirements. Developers
respect quality and organization
of our work, clients love it.
</p></li>
<li class="boton3 col-md-3"><img src="imagenes/icono-3.png" alt="web" class="center-block">
<p class="boton-textT">
WEB</p>
<p class="boton-textT">APPLICATIONS
</p>
<p class="boton-text col-md-12">
We are building UI for web
applications. We understand both:
the strength of trends
and technology constraints. At the
end of the day the user is still the
most important.
</p></li>
</div>
</ul>
</nav>
</section>
1. Your mark up is wrong
You wrapped the lis with div.contenedor this is not a standard practice. Please remove it.
2. Need a better understand bootstrap's grid system.
It's divided into 12 basically. If you want to put 3 items on a row and want them to be well-aligned horizontally, you need to use col-**-4, not -3 there.
Reading this http://getbootstrap.com/css/#grid will help you understand it better.
I editted some of your code here - http://jsfiddle.net/fktkeu9r/
Grids are based on 12:
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
As pointed out, the code needs to be cleaned up and validated.
You'll want to edit your CSS to something like:
.contenedor
{
margin-left: auto;
margin-right: auto;
width: 80%;
}

Bootstrap, how to align the caption to the right of the image within the thumbnail in a right way and align the button to the bottom of the caption?

As asked in the title, I am creating a website by using bootstrap v3.3.2.
The first question is that I am using the grid system to align the caption to the right of the thumbnail as shown below:
<div class="container">
<div class="thumbnail">
<div class="row">
<div class="col-md-6">
<a href="#">
<img class="img-responsive" src="images/pic.jpg">
</a>
</div>
<div class="col-md-6">
<div class="caption">
<h2>Title</h2>
<hr>
<p>A design specification provides explicit information about the requirements for a product and how the product is to be put together. It is the most traditional kind of specification, having been used historically in public contracting for buildings, highways, and other public works, and represents the kind of thinking in which architects and engineers have been trained.</p>
<hr>
<p class="caption-footer">
<span class="glyphicon glyphicon-heart"></span> Like it
<span class="glyphicon glyphicon-share"></span> Share it
</p>
</div>
</div>
</div>
</div>
</div>
Which turns out to be something like this:
As noticed, there is a large margin to the left of the image, which is not ideal. And when I resize the screen, it became more undesirable, with large margin to both side as shown below:
I think this may caused by the grid system since the col-md-6 has a fixed width. However I do not know how to fixe this.
The second question is that I try to align the two buttons to the bottom of the caption by adding a new class called caption-footer. However, this does not work.
Below is my CSS file for class caption-footer and how it turns out to be:
caption-footer{
position: absolute;
bottom:0;
left: 0;
}
I have checked quite a few links here (like: link1 link2). But none of them seems to work for my case.
Thanks in advance for any help!
One thing you can do simply place caption under col-md-12 div and buttons under another col-md-12 div.
<div class="container">
<div class="row">
<div class="col-md-6">
<a href="pulpitrock.jpg" class="thumbnail">
<p>Pulpit Rock: A famous tourist attraction in Forsand, Ryfylke, Norway.</p>
<img src="pulpitrock.jpg" alt="Pulpit Rock" width="284" height="213">
</a>
</div>
<div class="col-md-6">
<div class="col-md-12">
A design specification provides explicit information about the requirements for a product and how the product is to be put together. It is the most traditional kind of specification, having been used historically in public contracting for buildings, highways, and other public works, and represents the kind of thinking in which architects and engineers have been trained.
</div>
<div class="col-md-12">
Download
Images
</div>
</div>
</div>
</div>

Best Foundation html nesting practice

I am learning to write responsive pages using Foundation and I wonder if it is better to use Foundation as a template (for some top divs) or to use foundation row/column size-number classes all the way?
What I mean is should I write my HTML like this:
<body>
<div class="row">
<div class="small-8 column">
<div style="display: inline; width: 33%;"></div>
<div style="display: inline; width: 33%;"></div>
<div style="display: inline; width: 33%;"></div>
</div>
<div class="small-4 column">
<div style="display: inline; width: 33%;"></div>
<div style="display: inline; width: 33%;"></div>
<div style="display: inline; width: 33%;"></div>
</div>
</div>
</body>
Or like this:
<body>
<div class="row">
<div class="small-8 column">
<div class="row">
<div class="small-4 column></div>
<div class="small-4 column></div>
<div class="small-4 column></div>
</div>
</div>
<div class="small-4 column">
<div class="row">
<div class="small-4 column></div>
<div class="small-4 column></div>
<div class="small-4 column></div>
</div>
</div>
</div>
</body>
This example is trivial just to show what I am asking for. My question is related to deeper nestings (like 5+ levels of row>column).
The second approach is definitely better because:
Flexibility: size-number classes aren't only about floating layout, it's primary about responsivity. You are able to add some medium or large classes later and make different layout for different screens (this is not only about columns width but also about ability to change the position when a window is resized). Even if you don't suppose you need it now, who knows about future
Uniformity: size-number classes (and the column one) aren't only about sizing and positioning. They are also used for the uniform look and feel because they are defined by a complex style sheet. If you need to redefine the style you redefine the style for the whole applicatin in the same time so you don't overlook any. This is about spaces, margin, padding and much more.
Clarity: it is much more better to write CSS separatly in its files than styling in the code directly. Classes can be reused and CSS file is the first place where you looking for the style definitions (no matter if you are the new developer in the team or if you read your own code after a long time).
Compatibility: Foundation developers know their code and it there is much more chance that new version of the Foundation will be compatible with the old Foundation version better than with your own code.