Trying to add white space vertically between cols in a row - Bootstrap 4 - multiple-columns

I'm running into an issue here. I've used background images in each of my 8 columns in a row and now I need to add white space between them. I've created two classes here and they SHOULD work, but something is wrong. Also, I've used this in a past project and both thin-gutters and waffle were used in the row element, but now waffle only works on the child element of the col.
Here's my code...
<div id="products">
<div class="container-fluid">
<div class="row thin-gutters text-center">
<div class="col-12 col-md-6 col-xl-3 product-images waffle ceramic-tile">
<h2 class="product-title">Ceramic Tile</h2>
</div>
<div class="col-12 col-md-6 col-xl-3 product-images waffle carpet">
<h2 class="product-title"> carpet</h2>
</div>
<div class="col-12 col-md-6 col-xl-3 product-images waffle hardwood">
<h2 class="product-title">hardwood</h2>
</div>
<div class="col-12 col-md-6 col-xl-3 product-images waffle countertops">
<h2 class="product-title">countertops</h2>
</div>
<div class="col-12 col-md-6 col-xl-3 product-images waffle laminate">
<h2 class="product-title">laminate</h2>
</div>
<div class="col-12 col-md-6 col-xl-3 product-images waffle stone-tile">
<h2 class="product-title">stone tile</h2>
</div>
<div class="col-12 col-md-6 col-xl-3 product-images waffle vinyl">
<h2 class="product-title">vinyl</h2>
</div>
<div class="col-12 col-md-6 col-xl-3 product-images waffle area-rugs">
<h2 class="product-title">area rugs</h2>
</div>
</div>
</div>
and my css...
.thin-gutters {
margin-right: -2px;
margin-left: -2px;
}
#media (min-width: 576px) {
.thin-gutters {
margin-right: -2px;
margin-left: -2px;
}
}
#media (min-width: 768px) {
.thin-gutters {
margin-right: -2px;
margin-left: -2px;
}
}
#media (min-width: 992px) {
.thin-gutters {
margin-right: -2px;
margin-left: -2px;
}
}
#media (min-width: 1200px) {
.thin-gutters {
margin-right: -2px;
margin-left: -2px;
}
}
.thin-gutters > .col,
.thin-gutters > [class*="col-"] {
padding-right: 2px;
padding-left: 2px;
}
.waffle {
margin-bottom: 4px;
}
.waffle > .col,
.waffle > [class*="col-"] {
padding-bottom: 4px;
}

Add margin-bottom to the columns..
.thin-gutters > .col,
.thin-gutters > [class*="col-"] {
padding-right: 2px;
padding-left: 2px;
margin-bottom: 10px;
}
http://www.codeply.com/go/N9snQAKA4K
--
Update Bootstrap 4 beta
Now the spacing utils can be used for margins and padding. For example,
mb-2 for margin bottom of 2 spacing units.

Related

how to remove whitespace from bootstrap container row col divs

I'm using bootstrap and I'm getting free space at the very left and right of my div instead
of
taking up the entire screen it looks like it's only taking up 99%
MY CODE:
#social-links {
background-color : #242424;
/* border : .5px solid white; */
text-align : center;
color : white;
margin-bottom : -16px;
margin-top : -9px;
margin-left : 0px;
}
#social-links a {
color : white;
display : block;
width : 100%;
padding : 2px;
}
#social-links a:hover {
transition : 3s;
background-color : white;
color : black;
text-align : center;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css">
<div class="container-fluid border p-0 m-0 no-border">
<div class="row p-0 m-0">
<div class="col-4 p-0 mx-0 " id="social-links">
Discord
</div>
<div class="col-4 p-0 mx-0 " id="social-links">
Instagram
</div>
<div class="col-4 p-0 mx-0 " id="social-links">
Twitter
</div>
</div>
</div>
The apparent white-space comes from the default margin on the body element.
Also ~ you are using an ID three times, when an ID is unique to one HTML element. I changed social-links to a class.
.social-links {
background-color: #242424;
/* border: .5px solid white; */
text-align: center;
color: white;
margin-bottom: -16px;
margin-top: -9px;
margin-left: 0px;
}
.social-links a {
color: white;
display: block;
width: 100%;
margin: auto;
padding: 2px;
}
.social-links a:hover {
transition: 3s;
background-color: white;
color: black;
text-align: center;
}
body {
margin: 0;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css">
<div class="container-fluid border p-0 m-0 no-border">
<div class="row p-0 m-0">
<div class="col-4 p-0 mx-0 social-links">Discord
</div>
<div class="col-4 p-0 mx-0 social-links">Instagram
</div>
<div class="col-4 p-0 mx-0 social-links">Twitter
</div>
</div>
</div>
Edit ~ add body { margin: 0;} to remove the default margin on the body element.
i fixed it the problem was with class row margin and padding
FIXED:
Discord
Instagram
Twitter

text does not want to be under the image. using bootstrap

Hi guys do you know how to make this text under the image. i've tried use absolute on the text and it's work but when i test the responsive text gonna be the bottom of content not under the picture.
#sorryforbadenglish
.fitur {
padding: 15px 0;
text-align: center;
}
.fitur .btn-get-started {
font-family: "Roboto", sans-serif;
text-transform: uppercase;
font-weight: 500;
font-size: 14px;
letter-spacing: 1px;
display: inline-block;
padding: 10px 28px;
border-radius: 4px;
transition: 0.5s;
color: #fff;
background-image: url("../img/gplay.png");
background-size: cover;
width: 210px;
height: 61px;
}
.fitur .col-half-offset {
margin-left: 4.166666667%
}
.fitur p.sub {
font-size: 16px;
font-family: "Ubuntu", sans-serif;
font-weight: 700;
}
.fitur img {
max-width: 200%;
transition: all 0.4s ease-in-out;
display: inline-block;
padding: 15px 0;
}
.fitur img:hover {
transform: scale(1.15);
}
#media (max-width: 768px) {
.fitur img {
max-width: 100%;
}
}
#media (min-width: 1024px) {}
#media (max-width: 500px) {}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<section id="fitur" class="fitur section-bg">
<div class="container" data-aos="zoom-in">
<div class="section-title">
<p style="margin-top: 100px;">Fitur</p>
<h3>Aplikasi</h3>
</div>
<div class="row">
<div class="col-lg-2 d-flex align-items-center justify-content-center">
<img src="assets/img/aplikasi/01.png" class="img-fluid" alt="">
<p class="sub">Jual Sampah</p>
</div>
<div class="col-lg-2 col-half-offset d-flex align-items-center justify-content-center">
<img src="assets/img/aplikasi/02.png" class="img-fluid" alt="">
<p class="sub">Harga Real Time</p>
</div>
<div class="col-lg-2 col-half-offset d-flex align-items-center justify-content-center">
<img src="assets/img/aplikasi/05.png" class="img-fluid" alt="">
<p class="sub">Transaksi Terdata</p>
</div>
<div class="col-lg-2 col-half-offset d-flex align-items-center justify-content-center">
<img src="assets/img/aplikasi/06.png" class="img-fluid" alt="">
<p class="sub">Layanan Komunikasi</p>
</div>
<div class="col-lg-2 col-half-offset d-flex align-items-center justify-content-center">
<img src="assets/img/aplikasi/07.png" class="img-fluid" alt="">
<p class="sub">Rangkuman Transaksi</p>
</div>
</div>
<div class="d-flex">
</div>
</div>
</section>
the result is :
The text is next to the image, can you help me how to take it under the image ?
Add flex-column to the parent div which contains the image and text. Like this
<div class="col-lg-2 d-flex align-items-center justify-content-center flex-column">
<img src="assets/img/aplikasi/01.png" class="img-fluid" alt="">
<p class="sub">Jual Sampah</p>
</div>
By default the flex direction is row and it needs to be set to column so that the image and text are stacked on top of each other

How to center row with dynamic cols using CSS

I'm trying to center a row with dynamic number of cols. I can't set margins equal to both sides using Bootstrap row and col. I can center it if I use ul and li, but when the number of "Cards" does not occupy the whole row space, the items in that row are center aligned -- I want them to be left aligned. Follow my code
#font-face {
font-family: 'Hind';
src: url("../fonts/Hind/Hind-Regular.ttf"); }
body, nav, header, div, footer, section {
margin: 0px;
padding: 0px; }
body {
overflow: hidden;
background-color: #2F2E33;
font-family: "Hind"; }
header {
position: fixed;
top: 0;
right: 0;
left: 0;
min-height: 50px;
max-height: 90px; }
header .main-bar {
margin: 0px;
padding: 0px;
background-color: #2F2E33;
height: 50px; }
header .main-bar h1 {
padding: 0px;
margin: 0px;
color: #D7B135; }
header .main-menu {
height: 40px;
background-color: #D7B135; }
header .main-menu .inline-navbar {
margin: 0px;
padding: 0px;
height: 40px;
text-align: center; }
header .main-menu .inline-navbar li {
display: block;
float: left;
height: 40px;
padding: 0px 20px 0px 20px;
width: 20%;
line-height: 40px;
color: #FFFFFF;
cursor: pointer;
-webkit-transition: 0.2s;
transition: 0.2s; }
header .main-menu .inline-navbar li:hover {
background-color: #2F2E33;
color: #D7B135; }
#media screen and (max-width: 768px) {
.main-bar {
background-color: #D7B135; }
.main-bar h1 {
color: #2F2E33; } }
.profile-cardrow {
width: 100%;
display: block;
text-align: center; }
.profile-cardrow .profile-card {
vertical-align: top;
height: 30.0rem;
background-color: white;
margin: 20px;
padding: 0px;
min-width: 25.0rem;
max-width: 25.0rem; }
.profile-card {
height: 30.0rem;
background-color: white;
margin: 20px;
padding: 0px;
min-width: 25.0rem;
max-width: 25.0rem; }
.profile-list {
text-align: center;
padding: 0px; }
.profile-list .profile-item {
padding: 0px;
display: inline-block; }
.profile-list .profile-item .profile-card {
margin: 20px;
height: 30.0rem;
background-color: white;
min-width: 25.0rem;
max-width: 25.0rem;
padding: 0px; }
footer {
position: fixed;
bottom: 0;
right: 0;
left: 0;
min-height: 50px;
background-color: #2F2E33; }
.top-navbar {
background-color: #2F2E33;
margin: 0px;
padding: 0px;
border-style: none;
border-radius: 0px; }
.main-content {
position: fixed;
width: 100%;
bottom: 50px;
top: 90px;
overflow-y: scroll; }
<body>
<section>
<header>
<div class="main-bar">
<h1>pros</h1>
</div>
<nav class="main-menu">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<ul class="inline-navbar">
<li>Menu1</li>
<li>Menu2</li>
<li>Menu3</li>
<li>Menu4</li>
<li>Menu5</li>
</ul>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
</div>
</div>
</nav>
</header>
</section>
<section>
<div class="main-content">
<!--<div class="container-fluid">
<div class="row">
<div class="list-group">
<div class="col-xs-12 col-sm-6 col-med-4 col-lg-2 profile-card"></div>
<div class="col-xs-12 col-sm-6 col-med-4 col-lg-2 profile-card"></div>
<div class="col-xs-12 col-sm-6 col-med-4 col-lg-2 profile-card"></div>
<div class="col-xs-12 col-sm-6 col-med-4 col-lg-2 profile-card"></div>
<div class="col-xs-12 col-sm-6 col-med-4 col-lg-2 profile-card"></div>
<div class="col-xs-12 col-sm-6 col-med-4 col-lg-2 profile-card"></div>
<div class="col-xs-12 col-sm-6 col-med-4 col-lg-2 profile-card"></div>
<div class="col-xs-12 col-sm-6 col-med-4 col-lg-2 profile-card"></div>
<div class="col-xs-12 col-sm-6 col-med-4 col-lg-2 profile-card"></div>
<div class="col-xs-12 col-sm-6 col-med-4 col-lg-2 profile-card"></div>
</div>
</div>
</div>-->
<!--<div class="row profile-cardrow">
<div class="col-lg-2 col-md-4 col-sm-6 col-xs-12 profile-card"></div>
<div class="col-lg-2 col-md-4 col-sm-6 col-xs-12 profile-card"></div>
<div class="col-lg-2 col-md-4 col-sm-6 col-xs-12 profile-card"></div>
<div class="col-lg-2 col-md-4 col-sm-6 col-xs-12 profile-card"></div>
<div class="col-lg-2 col-md-4 col-sm-6 col-xs-12 profile-card"></div>
<div class="col-lg-2 col-md-4 col-sm-6 col-xs-12 profile-card"></div>
<div class="col-lg-2 col-md-4 col-sm-6 col-xs-12 profile-card"></div>
<div class="col-lg-2 col-md-4 col-sm-6 col-xs-12 profile-card"></div>
<div class="col-lg-2 col-md-4 col-sm-6 col-xs-12 profile-card"></div>
<div class="col-lg-2 col-md-4 col-sm-6 col-xs-12 profile-card"></div>
</div>-->
<ul class="profile-list">
<li class="profile-item"><div class="profile-card"></div></li>
<li class="profile-item"><div class="profile-card"></div></li>
<li class="profile-item"><div class="profile-card"></div></li>
<li class="profile-item"><div class="profile-card"></div></li>
<li class="profile-item"><div class="profile-card"></div></li>
<li class="profile-item"><div class="profile-card"></div></li>
<li class="profile-item"><div class="profile-card"></div></li>
<li class="profile-item"><div class="profile-card"></div></li>
<li class="profile-item"><div class="profile-card"></div></li>
<li class="profile-item"><div class="profile-card"></div></li>
<li class="profile-item"><div class="profile-card"></div></li>
<li class="profile-item"><div class="profile-card"></div></li>
<li class="profile-item"><div class="profile-card"></div></li>
</ul>
</div>
</section>
<section>
<footer>
<div></div>
</footer>
</section>
<script src="js/jquery-3.2.0.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
That's the way it is now:
That's the way i want, but with equals margins om both sides

Problems with bootstrap columns in extra small devices

I am experiencing a problem on bootstrap columns on extra small devices. In extra small devices the bootstrap columns overflow and changes the alignment.
I am attaching screenshots from extra small device and other device.
Screenshot of extra small device:
Screenshot of other device(working fine):
Below code is the bootstrap code.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="manu.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="header row">
<div class="time_remain col-sm-6 col-xs-6 col-md-6 col-ld-6">00 Min 00 Sec</div>
<div class="logout col-sm-6 col-xs-6 col-md-6 col-ld-6">Logout</div>
</div>
<div class="row frame">
<div class="col-sm-9 col-xs-9 col-md-9 col-ld-9 question_wrapper">
<div class="row questions">
1. This is first one?
</div>
<div class="row no-gutters choice_label_choice">
<div class="col-sm-1 col-xs-1 col-md-1 col-ld-1 answer_choice_label_div">
A
</div>
<div class="col-sm-11 col-xs-11 col-md-11 col-ld-11 answer_choice_div">
First
</div>
</div>
<div class="row no-gutters choice_label_choice">
<div class="col-sm-1 col-xs-1 col-md-1 col-ld-1 answer_choice_label_div">
B
</div>
<div class="col-sm-11 col-xs-11 col-md-11 col-ld-11 answer_choice_div">
Second
</div>
</div>
<div class="row no-gutters choice_label_choice">
<div class="col-sm-1 col-xs-1 col-md-1 col-ld-1 answer_choice_label_div">
C
</div>
<div class="col-sm-11 col-xs-11 col-md-11 col-ld-11 answer_choice_div">
Third
</div>
</div>
<div class="row no-gutters choice_label_choice">
<div class="col-sm-1 col-xs-1 col-md-1 col-ld-1 answer_choice_label_div">
D
</div>
<div class="col-sm-11 col-xs-11 col-md-11 col-ld-11 answer_choice_div">
Fourth
</div>
</div>
</div>
<div class="col-sm-3 col-xs-3 col-md-3 col-ld-3 question_status_wrapper">.col-sm-3</div>
</div>
<div class="row status_bar">
<div class="col-sm-3 col-xs-3 col-md-1 col-ld-1 time_bar"><div>00 MIN 00 SEC</div> </div>
<div class="col-sm-3 col-xs-3 col-md-1 col-ld-1 time_bar"><div>Back</div></div>
<div class="col-sm-3 col-xs-3 col-md-1 col-ld-1 time_bar"><div>Next</div></div>
<div class="col-sm-0 col-xs-0 col-md-6 col-ld-6 "></div>
<div class="col-sm-3 col-xs-3 col-md-1 col-ld-1 time_bar"><div>Submit</div></div>
</div>
</div>
</body>
</html>
The css code is given below.
.frame
{
height: 70vh;
}
.question_wrapper
{
height: inherit;
background-color: beige;
overflow: auto;
padding-left: 20px;
padding-right: 20px;
}
.time_remain
{
padding-top: 5px;
color: white;
text-align: left;
padding-left: 20px;
}
.logout
{
color: white;
text-align: right;
padding-right: 20px;
padding-top: 5px;
}
.question_status_wrapper
{
height: inherit;
background-color: bisque;
overflow: auto;
}
.header
{
height: 10vh;
background-color: #333333;
color: white;
}
.status_bar
{
position: fixed;
bottom: 0;
width: 100%;
height: 20vh;
background-color : #333333;
display: flex;
}
.questions
{
margin-top: 20px;
margin-left: 20px;
}
.answer_choice_label_div
{
background-color: black;
color: white;
text-align: center;
height: inherit;
vertical-align: inherit;
border-style: solid;
border-width: 2px;
}
.answer_choice_div
{
background-color: white;
color: black;
height: inherit;
vertical-align: inherit;
border-style: solid;
border-width: 2px;
overflow: inherit;
}
.answer_choice_div:hover
{
background-color: #C6FFF1;
color: black;
height: inherit;
vertical-align: inherit;
border-style: solid;
border-width: 2px;
overflow: inherit;
}
.choice_label_choice
{
margin-top: 10px;
margin-bottom: 10px;
min-height: 10vh;
height: 50px;
vertical-align: middle;
}
.time_bar
{
background-color: aliceblue;
color: black;
align-self: center;
text-align: center;
margin-left: 10px;
min-height: 6vh;
display: inline;
vertical-align: middle;
margin-right: 10px;
padding-top: 7px;
}
I have checked the bootstrap grid and didn't find any problem. Please help.
Use media queries , Paste this code in your style.css
#media only screen and (max-width: 580px)
{
.answer_choice_div
{
width: 83%;
}
.answer_choice_label_div
{
width: 10%;
}
}
Use xs for extra small devices. sm for small devices and md for medium devices.
Follow this link for Grid Options
Grid Options - Bootstrap

Bootstrap 3: Adjust size of cells in div row

How do I adjust the size of cells in a row such that their heights are equal and all the characters fit in them? This is how a row looks like right now:
Note the small characters in the Japanese column. The cell is not tall enough to accommodate them. Also, the height of the cell in the English column is less than that of the one next to it.
I want the row to look like this:
The background looks like a long, green rectangle.
Here is my CSS and HTML code:
<style type='text/css'>
/* For small screen */
.row :nth-child(even){
background-color: #FFFFFF;
}
.row :nth-child(odd){
background-color: #D0E9C6;
}
/* For medium screen */
#media (min-width: 768px) {
.row :nth-child(4n), .row :nth-child(4n-1) {
background-color: #FFFFFF;
}
.row :nth-child(4n-2), .row :nth-child(4n-3) {
background-color: #D0E9C6;
}
}
/* For large screen */
#media (min-width: 992px) {
.row :nth-child(6n), .row :nth-child(6n-1), .row :nth-child(6n-2) {
background-color: #FFFFFF;
}
.row :nth-child(6n-3), .row :nth-child(6n-4), .row :nth-child(6n-5) {
background-color: #D0E9C6;
}
}
.header, h1 { background-color: #FFFFFF !important}
.en-buffer { margin-top: 10px; margin-right: 10px }
.jp-buffer { margin-top: 10px; margin-left: 10px }
</style>
</head>
<body>
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12 header jp-buffer"><h1>Japanese</h1></div><div class="col-md-4 col-sm-6 col-xs-12 header en-buffer"><h1>English</h1></div>
</div>
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12 japanese jp-buffer"><ruby lang="jp">カレー</ruby><ruby lang="jp">粉<rp>(</rp><rt>こ</rt><rp>)</rp>は</ruby><ruby lang="jp">家<rp>(</rp><rt>いえ</rt><rp>)</rp>にあるの?</ruby></div><div class="col-md-4 col-sm-6 col-xs-12 english en-buffer">Do you have curry powder at your house?</div>
</div>
I think that the problem was the classes .en-buffer and .jp-buffer
try using padding instead margin...
/* For small screen */
.row:nth-child(even) {
background-color: #FFFFFF;
}
.row:nth-child(odd) {
background-color: #D0E9C6;
}
/* For medium screen */
#media (min-width: 768px) {
.row:nth-child(4n),
.row:nth-child(4n-1) {
background-color: #FFFFFF;
}
.row:nth-child(4n-2),
.row:nth-child(4n-3) {
background-color: #D0E9C6;
}
}
/* For large screen */
#media (min-width: 992px) {
.row:nth-child(6n),
.row:nth-child(6n-1),
.row:nth-child(6n-2) {
background-color: #FFFFFF;
}
.row:nth-child(6n-3),
.row:nth-child(6n-4),
.row:nth-child(6n-5) {
background-color: #D0E9C6;
}
}
.header,
h1 {
background-color: #FFFFFF !important
}
.en-buffer {
padding: 10px;
}
.jp-buffer {
padding: 10px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-6 header ">
<h1>Japanese</h1>
</div>
<div class="col-md-4 col-sm-6 col-xs-6 header ">
<h1>English</h1>
</div>
</div>
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-6 jp-buffer ">
<ruby lang="jp">カレー</ruby>
<ruby lang="jp">粉
<rp>(</rp>
<rt>こ</rt>
<rp>)</rp>は</ruby>
<ruby lang="jp">家
<rp>(</rp>
<rt>いえ</rt>
<rp>)</rp>にあるの?</ruby>
</div>
<div class="col-md-4 col-sm-6 col-xs-6 en-buffer">Do you have curry powder at your house?</div>
</div>