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.
Related
I have this issue where I need to apply some style to a div only if it's next to a visible item (even if there's non visible items in between, but not if all the items following the current one are all invisible), as shown here:
https://stackblitz.com/edit/js-3nulnw?file=style.css
.container {
display: flex;
flex-grow: 1;
padding: 5px;
}
.content {
border: 1px solid #000000;
border-radius: 4px;
width: 50%;
padding: 10px;
}
.addon {
width: 10%;
background-color: #ff0000;
border: 1px solid #000000;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-left: none;
}
.addon.hidden {
display: none;
}
.content:not(:last-child),
.addon:not(:last-child) {
border-right: none;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
<div class="container">
<div class="content">This is shown correctly (no addons)</div>
</div>
<div class="container">
<div class="content">This is shown correctly (one addon)</div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">
This is shown correctly (multiple addons, one is hidden)
</div>
<div class="addon hidden"></div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">This is shown correctly (multiple addons)</div>
<div class="addon"></div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">This should have all rounded borders</div>
<div class="addon hidden"></div>
</div>
<div class="container">
<div class="content">This should have all rounded borders</div>
<div class="addon"></div>
<div class="addon hidden"></div>
</div>
I have tried looking on the internet but to no avail, but I'm probably looking for the wrong answer (most of what I found were other SO questions saying there's no CSS selector for non visible item), so alternative ways to do this are welcome (possibly without JS)
Yes it is possible. I try to understand your question and get this result. Please expalin more your question
https://developer.mozilla.org/en-US/docs/Web/CSS/:is
We can get it through (:is) pseudo-class function. we can check if div has class like visible in below example case then we can apply style to its next div throught (+) adjacent sibling selector or (~) general sibling selector. I hope example will clear what I want to say
<div class="container">
<div class="content">This is shown correctly (no addons)</div>
</div>
<div class="container">
<div class="content">This is shown correctly (one addon)</div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">
This is shown correctly (multiple addons, one is hidden)
</div>
<div class="addon hidden"></div>
<div class="addon"></div>
</div>
<!-- [ADD 'visible' CLASS BEFORE OF TARGET CONTAINER] -->
<div class="container visible">
<div class="content">This is shown correctly (multiple addons)</div>
<div class="addon"></div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">This should have all rounded borders</div>
<div class="addon hidden"></div>
</div>
<div class="container">
<div class="content">This should have all rounded borders</div>
<div class="addon"></div>
<div class="addon hidden"></div>
</div>
and its css will be
.container {
display: flex;
flex-grow: 1;
padding: 5px;
}
.content {
border: 1px solid #000000;
border-radius: 4px;
width: 50%;
padding: 10px;
}
.addon {
width: 10%;
background-color: #ff0000;
border: 1px solid #000000;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-left: none;
}
.addon.hidden {
display: none;
}
.content:not(:last-child),
.addon:not(:last-child) {
border-right: none;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.container:is(.visible) + .container{
background-color: rebeccapurple;
color: white;
/* Your style here */
}
.container:is(.visible) + .container .addon{
background-color: brown;
color: white;
/* Your style here */
}
I found a horrible but apparently effective way of achieving what I wanted
https://stackblitz.com/edit/js-4hkorq?file=style.css
.container {
display: flex;
flex-grow: 1;
padding: 5px;
}
.content {
border: 1px solid #000000;
border-radius: 4px;
width: 50%;
padding: 10px;
}
.addon {
width: 10%;
background-color: #ff0000;
border: 1px solid #000000;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-left: none;
}
.addon.hidden {
/* display: none; */
visibility: hidden;
width: 0px;
}
.content:not(:last-child),
.addon:not(:last-child) {
border-right: none;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.container > div:last-of-type.hidden::before {
content: '';
border: 1px solid #000000;
border-radius: 4px;
border-left: none;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
height: 100%;
display: flex;
width: 4px;
visibility: visible;
position: relative;
top: -1px;
}
.container > .addon + div:last-of-type.hidden::before {
background-color: #ff0000;
}
<div class="container">
<div class="content">This is shown correctly (no addons)</div>
</div>
<div class="container">
<div class="content">This is shown correctly (one addon)</div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">
This is shown correctly (multiple addons, one is hidden)
</div>
<div class="addon hidden"></div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">This is shown correctly (multiple addons)</div>
<div class="addon"></div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">This should have all rounded borders</div>
<div class="addon hidden"></div>
</div>
<div class="container">
<div class="content">This should have all rounded borders</div>
<div class="addon"></div>
<div class="addon hidden"></div>
</div>
The trick is to use visibility: hidden and width: 0 instead of display: none, then add a ::before pseudo element that adds the border. It has the drawback of adding 4 pixels to the element (in order to have a 4 pixels border radius it needs to be at least 4 pixels wide) but it is acceptable in my case and (albeit with some tweaks) it also worked in my application.
For some reason I had to add top: -1px because it wouldn't align otherwise, but in my application I didn't need to do
These are the major changes to CSS
.container {display: table; table-layout: fixed; width: 100%...}
.addon {display: table-cell; position: relative; right: 5px;
z-index: 1; padding-right: 5px;...}
.addon+.addon {right: 10px; padding-right: 10px;...}
.content {display: table-cell;}
Since this is a pure CSS solution, the tags were changed so that :*-type-of works effectively. If you want a uniform height, add a div inside .content and give it an absolute height (ie px)
section:first-of-type > div {
border-top: 1px solid #000000;
}
section:last-of-type > div {
border-bottom: 1px solid #000000;
}
.container {
display: table;
table-layout: fixed;
width: 100%;
}
.content {
display: table-cell;
padding: 15px;
width: 50%;
border-left: 1px solid #000000;
border-right: 1px solid #000000;
border-top: 0.5px solid #000000;
border-bottom: 0.5px solid #000000;
border-radius: 4px;
}
.addon {
display: table-cell;
width: 10%;
position: relative;
right: 5px;
padding-right: 5px;
z-index: 1;
background-color: #ff0000;
border-left: 0;
border-right: 1px solid #000000;
border-top: 0.5px solid #000000;
border-bottom: 0.5px solid #000000;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.addon.hidden {
display: none;
}
.addon+.addon {
right: 10px;
padding-right: 10px;
}
<section class="container">
<div class="content">This is shown correctly (no addons)</div>
</section>
<section class="container">
<div class="content">This is shown correctly (one addon)</div>
<aside class="addon visible"></aside>
</section>
<section class="container">
<div class="content">
This is shown correctly (multiple addons, one is hidden)
</div>
<aside class="addon hidden"></aside>
<aside class="addon visible"></aside>
</section>
<section class="container">
<div class="content">This is shown correctly (multiple addons)</div>
<aside class="addon visible"></aside>
<aside class="addon visible"></aside>
</section>
<section class="container">
<div class="content">This should have all rounded borders</div>
<aside class="addon hidden"></aside>
</section>
<section class="container">
<div class="content">This should have all rounded borders</div>
<aside class="addon visible"></aside>
<aside class="addon hidden"></aside>
</section>
I'm creating a input to contain hours and minutes.I use this html elements:
Two pairs of up and down Buttons;
Input text.
I'm having trouble aligning the html elements.
This is the image with the best alignment I could apply:
This is my code:
.col-centered{
float: none;
margin: 0 auto;
}
.row-1{
padding-top: 3px;
padding-right: 0px;
padding-bottom: 1px;
padding-left: 0px;
}
.triangle-up {
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-bottom: 8px solid #555;
}
.triangle-down {
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 8px solid #555;
}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-1">
<div class="row-1">
<div class = "triangle-up" id ="up1"></div>
</div>
<div class="row-1">
<div class = "triangle-down" id ="down1"></div>
</div>
</div>
<div class="col-xs-2">
<div class = "col-centered">
<input type="text" id="hora" size="5" maxlength="5">
</div>
</div>
<div class="col-xs-1">
<div class="row-1">
<div class = "triangle-up" id ="up"></div>
</div>
<div class="row-1">
<div class = "triangle-down" id ="down"></div>
</div>
</div>
</div>
</div>
I tried, but without success, lining up the elements with pulling to the right. Forcing the left pair of Buttons, to be near the html text entry.
I've changed this piece of code:
<div class="pull-right">
<div class="row-1">
<div class = "triangle-up" id ="up1"></div>
</div>
<div class="row-1">
<div class = "triangle-down" id ="down1"></div>
</div>
</div>
How can I align the html elements so that the two pairs of buttons are close to the input element of text?
This would be a great use case for flexbox! Before, you had things inside the bootstrap grid, which was probably adding the extra spacing you didn't want. For a custom component look, you'd need to just space things out the way you want them to look. Now the triangles are spaced out evenly vertically - even if the height of the <input> is increased!
.spinner-input-wrapper {
display: flex;
}
.spinner {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.spinner-input {
margin: 0 3px;
}
.triangle-up,
.triangle-down {
width: 0;
height: 0;
border: 4px solid transparent;
}
.triangle-up {
border-bottom-width: 8px;
border-bottom-color: #555;
}
.triangle-down {
border-top-width: 8px;
border-top-color: #555;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container">
<div class="spinner-input-wrapper">
<div class="spinner">
<div class="triangle-up" id="up1"></div>
<div class="triangle-down" id="down1"></div>
</div>
<input type="text" class="spinner-input" size="5" maxlength="5">
<div class="spinner">
<div class="triangle-up" id="up2"></div>
<div class="triangle-down" id="down2"></div>
</div>
</div>
If you don't want to learn something else like flexbox all you really need is to clean up your code a bit. In this case the bootstrap layout is making it more difficult. Try simplifying to something like this. Here's my codepen sample
HTML
<div class="container">
<div class="triangles">
<div class="triangle-up" id="up1"></div>
<div class="triangle-down" id="down1"></div>
</div>
<div class="input-text">
<input type="text" id="hora" size="5" maxlength="5">
</div>
<div class="triangles">
<div class="triangle-up" id="up1"></div>
<div class="triangle-down" id="down1"></div>
</div>
</div>
CSS
.triangle-up {
margin-bottom: 6px;
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-bottom: 8px solid #555;
}
.triangle-down {
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 8px solid #555;
}
.triangles {
float: left;
display: inline-block;
padding: 2px 5px;
}
.input-text {
float: left;
display: inline-block;
}
I know it is dumb question, but i am struggling with following problem
It is one of my menu buttons. I want div the represents icon (marked red with circle) be on the left side of the button and the text on the right (name (blue) above description (purple)). By the way, i am going to have plenty of those buttons and i want them appear in column (block).
My current problem is that icon div (red) and text div (green dashed) wont place inline.
My HTML is:
<style>
.HomeMenuNavbarButton {
text-decoration: none;
color : black;
border-style:outset;
border-width:4px;
border-radius:15px;
display:block;
padding:4px;
}
.circle {
width: 50px;
height: 50px;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
border-radius: 25px;
border-color: black;
border-style: dashed;
display: inline-block;
vertical-align: top;
}
</style>
<div class="container">
<div class="row">
#foreach (var node in Model.Nodes)
{
if (!(node.IsRootNode) && node.Children.Any())
{
<div class="col-md-4">
<button type="button" style="display:inline;" class="btn btn-info" data-toggle="collapse" data-target="#("#relatedNavList" + node.Title) ">#node.Title</button>
<div id="#("relatedNavList" + node.Title)" class="collapse">
#foreach (var child in node.Children)
{
<div class="HomeMenuNavbarButton" style="display:block;">
<div style="background-color:red;display:inline">
<div class="circle">
</div>
</div>
<div style="border-color: green; border-style: dashed; display:inline-block">
<div style="background-color:blue">#(child.Title)</div>
<div style="background-color:purple">#(child.Description)</div>
</div>
</div>
}
</div>
</div>
}
}
</div>
</div>
When you want to display stuff side by side in CSS, the easiest way is to use flexbox. Try to add display : flex; to your HomeMenuNavBar class.
Here is a complete document about flexbox from the Mozilla team.
Using a wrapper defined as a flexbox
.wrapper {
display: flex;
align-items: center;
justify-content: space-between;
width: 150px;
}
.circle {
height: 25px;
width: 25px;
border: medium dashed darkgray;
border-radius: 50%;
}
button {
background: dodgerblue;
color: white;
border-radius: 3px;
border: thin solid lightblue;
padding: 0.5em;
}
<div class="wrapper">
<button>Button</button>
<div class="circle"></div>
<span>Text</span>
</div>
You can do that just with display:inline-block on your button's elements
.elementButton
{
display:inline-block;
}
.circle {
width: 50px;
height: 50px;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
border-radius: 25px;
border-color: black;
border-style: dashed;
display: inline-block;
vertical-align: top;
}
.HomeMenuNavbarButton
{
display:block;
margin:5px;
}
<div class="HomeMenuNavbarButton">
<div class="circle elementButton">
</div>
<div class="elementButton">
<div>Title one</div>
<div>Content</div>
</div>
</div>
<div class="HomeMenuNavbarButton">
<div class="circle elementButton">
</div>
<div class="elementButton">
<div >Title two</div>
<div>Content</div>
</div>
</div>
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>
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.