Bootstrap change $grid-gutter-width - html

I am using Bootstraps grid system and I need about a 2px space between each column. I've tried Column-Gap but nothing.
Could anyone help?
Code HTML:
<div class="container">
<div class="row">
<div class="col-md-3" id="one">
<h3>Pink</h3>
</div>
<div class="col-md-3" id="two">
<h3>Purple</h3>
</div>
<div class="col-md-3" id="three">
<h3>Green</h3>
</div>
<div class="col-md-3" id="four">
<h3>Orange</h3>
</div>
</div>
<div class="row2">
<div class="col-md-3" >
<h3>Things that are Pink</h3>
<p>Pigs</p>
<p>Barbie</p>
<p>Some Skins</p>
<p>Ham</p>
</div>
<div class="col-md-3" >
<h3>Things that are Purple</h3>
<p>Prince</p>
<p>Goths</p>
<p>Paint</p>
<p>Berries</p>
</div>
<div class="col-md-3" >
<h3>Things that are Green</h3>
<p>Grass</p>
<p>Peas</p>
<p>Leafs</p>
<p>Apple</p>
</div>
<div class="col-md-3" >
<h3>Things that are Orange</h3>
<p>Orange</p>
<p>Ice-Lolly</p>
<p>Essex</p>
<p>Carrots</p>
</div>
</div>
</div>
</body>
</html>
Code: CSS
body {
font-family: 'Roboto Mono', monospace;
}
#media screen and (min-width: 768px)
.jumbotron {
padding-top: 48px;
padding-bottom: 48px;
}
.jumbotron {
text-align: center;
}
.container {
text-align: center;
}
#one {
border: 5px solid pink;
border-radius: 20px;
background-color: pink;
color: white;
}
#two {
border: 5px solid purple;
border-radius: 20px;
background-color: purple;
color: white;
}
#three {
border: 5px solid green;
border-radius: 20px;
background-color: green;
color: white;
}
#four {
border: 5px solid orange;
border-radius: 20px;
background-color: orange;
color: white;
}
.row2 {
margin-top: 30px;
margin-right: -15px;
margin-left: -15px;
}

A quick guide to resizing Bootstrap’s gutter width
Resizing Bootstrap's Gutter
A simple method of changing Bootstrap's default gutter size.
HTML
<div class="gutter-2 row">
<div class="col-md-6"></div>
<div class="col-md-6"></div>
`
CSS
.gutter-2.row {
margin-right: -1px;
margin-left: -1px;
}
.gutter-2 > [class^="col-"], .gutter-2 > [class^=" col-"] {
padding-right: 1px;
padding-left: 1px;
}`

to change the gutter you have two way:
change #grid-gutter-width in variables.less:327, but then you will need to compile the generated css yourself.
change #grid-gutter-width and download a new custom build at Bootstrap#Customize
Note that the customize section will be dropped in twitter bootstrap 4.

Related

CSS place N divs inline-block column by column (vertically)

The code below shows what I have but it is not user friendly way to show data(time). "display:inline-block" puts elements in a row and after it reaches parent div's width it puts his next child in the next row.
.rateDates {
display: inline-block;
margin: 10px;
font-family: consolas;
border: 1px solid #73d5e6;
border-radius: 15px;
padding: 4px 8px 4px 8px;
}
#ratesContainer {
border: 1px solid #73d5e6;
padding: 15px;
border-radius: 10px;
margin-top: 20px;
margin-bottom: 20px;
height:200px;
}
<div id="ratesContainer">
<div class="rateDates">
<span>00:00:00</span>
</div>
<div class="rateDates">
<span>11:11:11</span>
</div>
<div class="rateDates">
<span>22:22:22</span>
</div>
<div class="rateDates">
<span>33:33:33</span>
</div>
<div class="rateDates">
<span>44:44:44</span>
</div>
<div class="rateDates">
<span>55:55:55</span>
</div>
</div>
The problem is I can't make it place child div's on top of each other and after the parent div's height is not enaugh start from top again. In other words start a new column.
I want to place rateDates class divs in column way. So they first fill up not the row but the column.
Page renders automatycally. I need a CSS solution. If it is posible.
Thank you.
use a flex property.
Here is updated code.
CSS
.rateDates {
margin: 10px;
font-family: consolas;
border: 1px solid #73d5e6;
border-radius: 15px;
padding: 4px 8px 4px 8px;
}
#ratesContainer {
border: 1px solid #73d5e6;
padding: 15px;
border-radius: 10px;
margin-top: 20px;
margin-bottom: 20px;
height:200px;
display:flex;
flex-direction:column;
flex-wrap:wrap
}
HTML
<div id="ratesContainer">
<div class="rateDates">
<span>00:00:00</span>
</div>
<div class="rateDates">
<span>11:11:11</span>
</div>
<div class="rateDates">
<span>22:22:22</span>
</div>
<div class="rateDates">
<span>33:33:33</span>
</div>
<div class="rateDates">
<span>44:44:44</span>
</div>
<div class="rateDates">
<span>55:55:55</span>
</div>
</div>
You can do it the Flexbox:
#ratesContainer {
display: flex; /* displays flex-items (children) inline */
border: 1px solid #73d5e6;
padding: 15px;
border-radius: 10px;
margin: 20px 0;
}
#ratesContainer > .rateDates {
flex: 1;
text-align: center;
margin: 10px;
font-family: consolas;
border: 1px solid #73d5e6;
border-radius: 15px;
padding: 4px 8px;
}
#media (max-width: 768px) { /* adjust */
#ratesContainer {
flex-direction: column; /* stacks children vertically */
align-items: center; /* because of the changed direction this is now horizontal centering, otherwise it's vertical by default */
}
}
<div id="ratesContainer">
<div class="rateDates">
<span>00:00:00</span>
</div>
<div class="rateDates">
<span>11:11:11</span>
</div>
<div class="rateDates">
<span>22:22:22</span>
</div>
<div class="rateDates">
<span>33:33:33</span>
</div>
<div class="rateDates">
<span>44:44:44</span>
</div>
<div class="rateDates">
<span>55:55:55</span>
</div>
</div>
It's a bit different approach but the end result is what you want, i.e. display them in one column vertically.
Just to mention an alternative approach, this can be also done with multi-column layout:
.rateDates {
display: inline-block;
margin: 10px;
font-family: consolas;
border: 1px solid #73d5e6;
border-radius: 15px;
padding: 4px 8px 4px 8px;
}
#ratesContainer {
border: 1px solid #73d5e6;
padding: 15px;
border-radius: 10px;
margin-top: 20px;
margin-bottom: 20px;
height:200px;
column-width: 110px;
column-fill: auto;
}
<div id="ratesContainer">
<div class="rateDates">
<span>00:00:00</span>
</div>
<div class="rateDates">
<span>11:11:11</span>
</div>
<div class="rateDates">
<span>22:22:22</span>
</div>
<div class="rateDates">
<span>33:33:33</span>
</div>
<div class="rateDates">
<span>44:44:44</span>
</div>
<div class="rateDates">
<span>55:55:55</span>
</div>
</div>
But I prefer the Flexbox solution. These items don't look like parts of the text flow, that inline-block was designed for. And with Flexbox you will not need to hardcode the width of the column.

HTML - change image inside frame and keep frame size intact

My main goal is to have a simple frame (as you can see) with few text lines and images. The thing I want to do, is make this frame flexible. By that I mean - if I change picture inside of it (bigger -> smaller) the frame should change. It should stay fixed.
Online editor: https://www.bootply.com/Y09Zn1wir3#
HTML:
<div class="col-md-4">
<div class="single-image-wrap">
<div class="single-image">
<div class="name">NAME</div>
<div class="img-wrap">
<img src="https://cdn.pixabay.com/photo/2013/07/12/14/07/basketball-147794_960_720.png" class="first-image">
</div>
<div class="extra-info">
<div class="bottom-text">ABC</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="single-image-wrap">
<div class="single-image">
<div class="name">NAME</div>
<div class="img-wrap">
<img src="https://cdn.pixabay.com/photo/2013/07/12/14/07/basketball-147794_960_720.png" class="second-image">
</div>
<div class="extra-info">
<div class="bottom-text">ABC</div>
</div>
</div>
</div>
</div>
CSS:
/* CSS used here will be applied after bootstrap.css */
.single-image{
border: 1px solid orange;
width: 100%;
text-align: center;
margin: 0px 0px 15px 0px;
float: right;
}
.name{
padding: 20px 0px 0px 0px;
color: black;
height: 75px;
font-size: 18px;
}
.img-wrap{
padding-bottom: 50px;
padding-top: 25px;
}
.first-image{
width: 200px;
}
.second-image{
width: 150px;
}
.extra-info{
border-top: 1px solid orange;
}
.bottom-text{
padding-top: 15px;
height: 50px;
letter-spacing: 0.1em;
}
I tried to add height property to such as:
.single-image{
...
height: 405px;
}
Result: https://www.codeply.com/go/2s2hH3nbju
But it doesn't look correct, as bottom text floats somewhere up.
I need a solution for different type of image sizes. Any ideas?
You need to set the height of .img-wrap, too.
.single-image{
border: 1px solid orange;
width: 100%;
text-align: center;
margin: 0px 0px 15px 0px;
float: right;
height: 405px;
}
.img-wrap{
padding-bottom: 50px;
padding-top: 25px;
height:250px;
overflow:hidden;
}
Try to add this new line in your css code.
.img-wrap{
min-height: 275px;
}
it will looks like this
Output
Try using flex
.single-image{
border: 1px solid orange;
width: 100%;
text-align: center;
display: flex;
flex-direction: column;
height: 100%;
justify-content: space-between;
}
.name{
padding: 20px 0px 0px 0px;
color: black;
height: 75px;
font-size: 18px;
}
.img-wrap{
padding-bottom: 50px;
padding-top: 25px;
}
.first-image{
width: 200px;
}
.second-image{
width: 150px;
}
.extra-info{
border-top: 1px solid orange;
align-self: bottom;
}
.bottom-text{
padding-top: 15px;
height: 50px;
letter-spacing: 0.1em;
}
.images-wrap{
display: flex;
}
.single-image-wrap {
height: 100%;
margin-bottom: 15px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="row images-wrap">
<div class="col-xs-6 col-md-4">
<div class="single-image-wrap">
<div class="single-image">
<div class="name">NAME</div>
<div class="img-wrap">
<img src="https://cdn.pixabay.com/photo/2013/07/12/14/07/basketball-147794_960_720.png" class="first-image">
</div>
<div class="extra-info">
<div class="bottom-text">ABC</div>
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="single-image-wrap">
<div class="single-image">
<div class="name">NAME</div>
<div class="img-wrap">
<img src="https://cdn.pixabay.com/photo/2013/07/12/14/07/basketball-147794_960_720.png" class="second-image">
</div>
<div class="extra-info">
<div class="bottom-text">ABC</div>
</div>
</div>
</div>
</div>
</div>

Alternative to display flex for event tracker

I currently have an event tracker made using html and css. My issue is that I would like to get ride of display: flex; due to browser-compatibility issues. Is there an alternative to achieve the same result? I tried using display:inline-block because without flex all steps were coming in different lines.
HTML:
<div class="container">
<div class="row event">
<div class="col-xs-3 event-step">
<p class="event-stepnum">Step 1</p>
<div class="progress">
<div class="progress-bar"></div>
</div>
</div>
<div class="col-xs-3 event-step complete">
<p class="event-stepnum">Step 2</p>
<div class="progress">
<div class="progress-bar"></div>
</div>
</div>
<div class="col-xs-3 event-step">
<p class="event-stepnum">Step 3</p>
<div class="progress">
<div class="progress-bar"></div>
</div>
</div>
</div>
</div>
CSS:
.event > .event-step {
padding: 0;
position: relative;
}
.event > .event-step .event-stepnum {
color: #595959;
font-size: 16px;
margin-bottom: 5px;
}
.steps .step-on,
.steps .step-done {
background-color: #1b7e28;
color: #1b7e28;
border: 1px solid transparent;
}
.progress {
position: relative;
border-radius: 0px;
height: 5px;
box-shadow: none;
margin: 20px 0;
}
.progress > .progress-bar {
width: 0px;
box-shadow: none;
background: #fbe8aa;
}
.event-step.complete > .progress > .progress-bar {
width: 100%;
}
.row {
display:flex;
}
JSFiddle Demo
Just replace the display:flex by display:inline-block and give your step divs a fixed width:
.event > .event-step {
padding: 0;
position: relative;
width: 200px;
}
.row {
display: inline-block;
}
https://jsfiddle.net/onk2cqhg/

Center according to element that has sibling with a larger width

I have a group of stats styled as shown below, but if I want to center the group, it will use the width of the descriptions that extend past and have a larger width. What's the easiest way to center according to the width of just the stat numbers and still have the descriptions below them?
.container {
text-align: center;
}
.stats {
display: block;
margin: 0 auto 30px auto;
}
.left-stats {
text-align: right;
display: inline-block;
margin-right: 40px;
}
.left-stats .single-stat {
text-align: right;
}
.right-stats {
display: inline-block;
}
.right-stats .single-stat {
text-align: left;
}
.single-stat {
margin-bottom: 20px;
}
.number {
font: 60px"Bebas Neue";
font-weight: bold;
margin-bottom: -5px;
}
<div class="container">
<h3>Header</h3>
<div class="stats">
<div class="left-stats">
<div class="single-stat">
<div class="number">1,200</div>
<div class="desc">Staff on campus supported</div>
</div>
<div class="single-stat">
<div class="number">10</div>
<div class="desc">Departments reached</div>
</div>
</div>
<div class="right-stats">
<div class="single-stat">
<div class="number">06</div>
<div class="desc">Different home states/countries</div>
</div>
<div class="single-stat">
<div class="number">10</div>
<div class="desc">People who love food and technology</div>
</div>
</div>
</div>
</div>
I have a solution using your HTML and using display: table-cell instead of display: inline-block. Instead of a 40px margin to create the space between the columns, I added 20px left/right padding in the relevant elements.
Note that I added dotted blue borders for demonstration purposes, you can remove them.
.container {
text-align: center;
}
.stats {
display: table;
width: 100%;
margin: 0 auto 30px auto;
border: 1px dotted blue;
}
.left-stats {
text-align: right;
display: table-cell;
width: 50%;
padding-right: 20px;
border: 1px dotted blue;
}
.left-stats .single-stat {
text-align: right;
}
.right-stats {
display: table-cell;
width: 50%;
padding-left: 20px;
border: 1px dotted blue;
}
.right-stats .single-stat {
text-align: left;
}
.single-stat {
margin-bottom: 20px;
}
.number {
font: 60px"Bebas Neue";
font-weight: bold;
margin-bottom: -5px;
}
<div class="container">
<h3>Header</h3>
<div class="stats">
<div class="left-stats">
<div class="single-stat">
<div class="number">1,200</div>
<div class="desc">Staff on campus supported</div>
</div>
<div class="single-stat">
<div class="number">10</div>
<div class="desc">Departments reached</div>
</div>
</div>
<div class="right-stats">
<div class="single-stat">
<div class="number">06</div>
<div class="desc">Different home states/countries</div>
</div>
<div class="single-stat">
<div class="number">10</div>
<div class="desc">People who love food and technology</div>
</div>
</div>
</div>
</div>
You mean something like this?
.number {
font: 60px"Bebas Neue";
font-weight: bold;
margin-bottom: -5px;
text-align: center;
}

Bringing the p and div in the same line

I have type of card created. It has 3 rows with a p and a div. I want both of them to come in the same line. How can I do this?
HTML:
<div class="user_card">
<div class="skills">
<p>Skills</p>
<div class="progress_wrap">
<div class="progress" style="width:95%"></div>
</div>
</div>
<div class="commitment">
<p>Commitment</p>
<div class="progress_wrap">
<div class="progress" style="width:35%;"></div>
</div>
</div>
<div class="reputation">
<p>Reputation</p>
<div class="progress_wrap">
<div class="progress" style="width:65%;"></div>
</div>
</div>
</div>
CSS:
.user_card {
background-color: #eee;
width: 30%;
padding: 10px;
}
.user_card div p {
display: inline;
}
.user_card div.skills {
margin-left: -1px;
}
.user_card div div.progress_wrap {
background-color: white;
width: 100%;
border: 1px solid #bbb;
}
.user_card div div.progress {
height: 30px;
background-color: #ddd;
}
Fiddle.
Please post fiddle as well with your answers!
Using display table, table-row, table-cell.
http://jsfiddle.net/vnama/
.user_card {
background-color: #eee;
width: 30%;
padding: 10px;
display:table;
}
.user_card p {
display: table-cell;
vertical-align:top;
line-height:30px;
padding:2px 10px 2px 2px;
}
.user_card div {
display:table-row;
padding:2px;
}
.user_card div div {
display:table-cell;
}
.user_card div div.progress_wrap {
background-color: white;
width: 100%;
border: 1px solid #bbb;
}
.user_card div div.progress {
height: 30px;
background-color: #ddd;
}
You can try using tables: http://jsbin.com/efugop
I have it:
HTML:
<div class="user_card">
<div class="skills">
<table><tr><td>
<p>Skills</p></td><td>
<div class="progress_wrap" style="margin-left:70px;">
<div class="progress" style="width:95%"></div>
</div></td></tr></table></div>
<div class="commitment">
<table><tr><td>
<p style="position:relative;margin-top:6px;">Commitment</p>
<div class="progress_wrap" style="position:relative;left:35px;margin-left:70px;">
<div class="progress" style="width:35%;"></div>
</div></td></tr></table>
</div>
<div class="reputation">
<table><tr><td>
<p style="position:relative;margin-top:6px;">Reputation</p>
<div class="progress_wrap" style="position:relative;left:35px;margin-left:70px;">
<div class="progress" style="width:65%;"></div>
</div>
</td></tr></table>
</div>
</div>
CSS:
.user_card {
background-color: #eee;
width: 50%;
padding: 20px 80px 20px 20px;
}
.user_card div p {
display: inline;
float: left;
}
.user_card div.skills {
margin-left: -1px;
}
.user_card div div.progress_wrap {
background-color: white;
width: 100px;
border: 1px solid #bbb;
}
.user_card div div.progress {
height: 30px;
background-color: #ddd;
}
You can use css to float left
. progress_wrap {
float: right;
}
HTML
<div class="user_card">
<div class="skills">
<p>Skills</p>
<div class="progress_wrap" style="margin-left:80px;">
<div class="progress" style="width:95%"></div>
</div>
</div>
<div class="commitment">
<p style="margin-left:-35px;">Commitment</p>
<div class="progress_wrap" style="margin-left:80px;">
<div class="progress" style="width:35%;"></div>
</div>
</div>
<div class="reputation">
<p style="margin-left:-73px;">Reputation</p>
<div class="progress_wrap" style="margin-left:80px;">
<div class="progress" style="width:65%;"></div>
</div>
</div>
In CSS
.user_card {
background-color: #eee;
width: 50%;
padding: 20px 100px 20px 20px;
}
.user_card div p {
display: inline;
float: left;
}
.user_card div.skills {
margin-left: -1px;
}
.user_card div div.progress_wrap {
background-color: white;
width: 100%;
border: 1px solid #bbb;
}
.user_card div div.progress {
height: 30px;
background-color: #ddd;
}