Put sticky hyphens in text input - html

I need to put sticky hyphens in a text input. I attached an image of what I need. I have marked in red what should be fixed. The first hyphen should be after three number gaps, the next after two gaps, and so on.
The numbers appear as I click on each number but I want the dashes to appear by default.
I have tried to do it with a span but I have not succeeded.
<div class="row">
<p id="p" style="font-size: 30px;">Introduzca ubicaciĆ³n:<input style="margin-left: 10px; font-size: 30px;"
type="text" [value]="codeNum" id="code" placeholder="___-__-__-__-__">
<button type="button" style="margin-left: 10px; font-size: 30px; border: white 3px solid;"
class="btn btn-dark btn-lg" (click)="clear()">Borrar</button>
<button type="button" style="margin-left: 10px; font-size: 30px; border: white 3px solid;"
class="btn btn-dark btn-lg" (click)="allClear()">Borrar todo</button>
</p>
</div>
</div>
<div class="calculator-keys">
<button type="button" class="btn btn-light waves-effect" (click)="pressNum('0')" value="0">0</button>
<button type="button" class="btn btn-light waves-effect" (click)="pressNum('1')" value="1">1</button>
<button type="button" class="btn btn-light waves-effect" (click)="pressNum('2')" value="2">2</button>
<button type="button" class="btn btn-light waves-effect" (click)="pressNum('3')" value="3">3</button>
<button type="button" class="btn btn-light waves-effect" (click)="pressNum('4')" value="4">4</button>
<button type="button" class="btn btn-light waves-effect" (click)="pressNum('5')" value="5">5</button>
<button type="button" class="btn btn-light waves-effect" (click)="pressNum('6')" value="6">6</button>
<button type="button" class="btn btn-light waves-effect" (click)="pressNum('7')" value="7">7</button>
<button type="button" class="btn btn-light waves-effect" (click)="pressNum('8')" value="8">8</button>
<button type="button" class="btn btn-light waves-effect" (click)="pressNum('9')" value="9">9</button>
</div>
Thank you

If you're open to using packages there's some out there that might fit your needs. E.g. ngx-mask
npm i --save ngx-mask
then you can do
<input type="text" mask="000-00-00-00-00" [(ngModel)]="codeNum">
OR
<p>{{ codeNum | mask: '000-00-00-00-00' }}</p>
Example: https://stackblitz.com/edit/angular-ngx-mask-example-zd89hh?file=src%2Fapp%2Fapp.component.html

Related

Make buttons clean on mobile view

First of all I am a noob of CSS. Also I am using bootstrap framework. I have a question. Recently I created a set of buttons and they are viewable on mobile devices too.
Desktop view:
https://i.stack.imgur.com/C8JCp.png
Mobile view:
https://i.stack.imgur.com/IBPP0.png
So what I want to do is I need to give some small space between rows on mobile device view.
Like this: https://i.stack.imgur.com/fU55k.png
My Code:
<?php
include "header.php";
include "navbar.php";
?>
<div style="text-align: center;">
<button type="button" class="btn btn-info">January</button>
<button type="button" class="btn btn-info">February</button>
<button type="button" class="btn btn-info">March</button>
<button type="button" class="btn btn-info">April</button>
<button type="button" class="btn btn-info">May</button>
<button type="button" class="btn btn-info">June</button>
<button type="button" class="btn btn-info">July</button>
<button type="button" class="btn btn-info">August</button>
<button type="button" class="btn btn-info">September</button>
<button type="button" class="btn btn-info">October</button>
<button type="button" class="btn btn-info">November</button>
<button type="button" class="btn btn-info">December</button>
</div>
<?php
include "footer.php"
?>
Anyone help for this? Thanks in Advance. Also sorry for my bad English.
So for that you have to set bottom margin of 5px for all buttons like below
.btn-Margin{
margin-bottom : 5px
}
<div style="text-align: center;">
<button type="button" class="btn btn-info btn-Margin">January</button>
<button type="button" class="btn btn-info btn-Margin">February</button>
<button type="button" class="btn btn-info btn-Margin">March</button>
<button type="button" class="btn btn-info btn-Margin">April</button>
<button type="button" class="btn btn-info btn-Margin">May</button>
<button type="button" class="btn btn-info btn-Margin">June</button>
<button type="button" class="btn btn-info btn-Margin">July</button>
<button type="button" class="btn btn-info btn-Margin">August</button>
<button type="button" class="btn btn-info btn-Margin">September</button>
<button type="button" class="btn btn-info btn-Margin">October</button>
<button type="button" class="btn btn-info btn-Margin">November</button>
<button type="button" class="btn btn-info btn-Margin">December</button>
</div>

Set bootstrap spacing for all nested items

Say I have this snipped of HTML code:
<div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary"><span class="oi oi-media-step-backward" title="Rewind" aria-hidden="true"></span></button>
<button type="button" class="btn btn-secondary"><span class="oi oi-media-play" title="Play" aria-hidden="true"></span></button>
<button type="button" class="btn btn-secondary"><span class="oi oi-media-pause" title="Pause" aria-hidden="true"></span></button>
</div>
<button type="button" class="btn btn-danger"><span class="oi oi-media-record" title="Pause" aria-hidden="true"></span></button>
<button type="button" class="btn btn-warning">Clear</button>
</div>
I would like any item inside the outer div have an horizontal margin of 3.
The only way I know is to add me-3 to the class of each item (the button group and the two other buttons). But I have to remember to add this for any other item I'm going to add.
I tried to add this to the outer div, but of course it refers to the next sibling div (if any).
Is there a way to set this margin in the outer div, but to be applied to the nested elements?
JS Solution
Iterate over all of the outer div children, and setAttribute class `me-3` to each one:
let outerDiv = document.querySelector(".btn-group")
for (let i = 0; i < outerDiv.childNodes.length; i++) {
console.log(outerDiv.childNodes[i])
if (i % 2 == 1) {
outerDiv.childNodes[i].setAttribute("class", "me-3");
}
}
<div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary"><span class="oi oi-media-step-backward" title="Rewind" aria-hidden="true"></span></button>
<button type="button" class="btn btn-secondary"><span class="oi oi-media-play" title="Play" aria-hidden="true"></span></button>
<button type="button" class="btn btn-secondary"><span class="oi oi-media-pause" title="Pause" aria-hidden="true"></span></button>
</div>
<button type="button" class="btn btn-danger"><span class="oi oi-media-record" title="Pause" aria-hidden="true"></span></button>
<button type="button" class="btn btn-warning">Clear</button>
</div>
CSS Solution
Similar to the JS solution, use `>` to iterate over all the children of `.btn-group`:
.btn-group > button {
margin-left: 3px;
margin-right: 3px;
}
<div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-secondary"><span class="oi oi-media-step-backward" title="Rewind" aria-hidden="true"></span></button>
<button type="button" class="btn btn-secondary"><span class="oi oi-media-play" title="Play" aria-hidden="true"></span></button>
<button type="button" class="btn btn-secondary"><span class="oi oi-media-pause" title="Pause" aria-hidden="true"></span></button>
</div>
<button type="button" class="btn btn-danger"><span class="oi oi-media-record" title="Pause" aria-hidden="true"></span></button>
<button type="button" class="btn btn-warning">Clear</button>
</div>
I personally recommend the CSS solution as you can change the margin left and right to your liking.

Bootstrap I want to have a five column layout on desktop but two columns on mobile

I want 20 buttons in 4x5 fashion on desktop but on mobile 10x2 fashion. Here is my jfiddle
<div class="container">
<div class="col-md-12">
<button type="button" style="background-color:white" class="btn btn-default btn-square">white</button>
<button type="button" style="background-color:#F7F6E4" class="btn btn-default btn-square">Beige</button>
<button type="button" style="background-color:#3BA6F8" class="btn btn-default btn-square">Blau</button>
<button type="button" style="background-color:#F36660" class="btn btn-default btn-square">Rot</button>
<button type="button" style="background-color:#FDFCEA" class="btn btn-default btn-square">Creme</button>
</div>
<div class="col-md-12">
<button type="button" style="background-color:#DBDBDB" class="btn btn-default btn-square">Graue</button>
<button type="button" style="background-color:#E6C08E" class="btn btn-default btn-square">Eiche</button>
<button type="button" style="background-color:#358B9F" class="btn btn-default btn-square">Petrol</button>
<button type="button" style="background-color:#FF7ECD" class="btn btn-default btn-square">Rosa</button>
<button type="button" style="background-color:#C9C9C9" class="btn btn-default btn-square">Silber</button>
</div>
<div class="col-md-12">
<button type="button" style="background-color:#505558;color:white;" class="btn btn-default btn-square">Anthrazit</button>
<button type="button" style="background-color:C39881" class="btn btn-default btn-square">Taupe</button>
<button type="button" style="background-color:#569A9E" class="btn btn-default btn-square">Trukis</button>
<button type="button" style="background-color:#A03A97" class="btn btn-default btn-square">Lila</button>
<button type="button" style="background-color:#FFDB53" class="btn btn-default btn-square">Gold</button>
</div>
<div class="col-md-12">
<button type="button" style="background-color:#2E2E2E;color:white;" class="btn btn-default btn-square">Schwarz</button>
<button type="button" style="background-color:#A16340" class="btn btn-default btn-square">Braun</button>
<button type="button" style="background-color:#C9DDA8" class="btn btn-default btn-square">Grun</button>
<button type="button" style="background-color:#FFB24A" class="btn btn-default btn-square">Orange</button>
<button type="button" style="background-color:#FFFD5E" class="btn btn-default btn-square">Gelb</button>
</div>
</div>
I could not find anything useful online. I am not using any trick here. Basically I am using button sizes so that it appears in 5 column and then it should appear in 2 column on mobile, but it does not work.
If you want to write less code and avoid so many col-* classes...Use Flexbox
Updated Fiddle
Stack Snippet
.btn-row {
display: flex;
flex-wrap: wrap;
}
.btn.btn-square {
flex: 0 0 calc(20% - 10px);
border-radius: 0;
margin: 5px;
}
#media (max-width:576px) {
.btn.btn-square {
flex: 0 0 calc(50% - 10px);
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<h1 class="text-center">Bootstrap Buttons</h1>
<div class="container">
<div class="btn-row">
<button type="button" style="background-color:white" class="btn btn-default btn-square col-md">white</button>
<button type="button" style="background-color:#F7F6E4" class="btn btn-default btn-square">Beige</button>
<button type="button" style="background-color:#3BA6F8" class="btn btn-default btn-square">Blau</button>
<button type="button" style="background-color:#F36660" class="btn btn-default btn-square">Rot</button>
<button type="button" style="background-color:#FDFCEA" class="btn btn-default btn-square">Creme</button>
<button type="button" style="background-color:#DBDBDB" class="btn btn-default btn-square">Graue</button>
<button type="button" style="background-color:#E6C08E" class="btn btn-default btn-square">Eiche</button>
<button type="button" style="background-color:#358B9F" class="btn btn-default btn-square">Petrol</button>
<button type="button" style="background-color:#FF7ECD" class="btn btn-default btn-square">Rosa</button>
<button type="button" style="background-color:#C9C9C9" class="btn btn-default btn-square">Silber</button>
<button type="button" style="background-color:#505558;color:white;" class="btn btn-default btn-square">Anthrazit</button>
<button type="button" style="background-color:C39881" class="btn btn-default btn-square">Taupe</button>
<button type="button" style="background-color:#569A9E" class="btn btn-default btn-square">Trukis</button>
<button type="button" style="background-color:#A03A97" class="btn btn-default btn-square">Lila</button>
<button type="button" style="background-color:#FFDB53" class="btn btn-default btn-square">Gold</button>
<button type="button" style="background-color:#2E2E2E;color:white;" class="btn btn-default btn-square">Schwarz</button>
<button type="button" style="background-color:#A16340" class="btn btn-default btn-square">Braun</button>
<button type="button" style="background-color:#C9DDA8" class="btn btn-default btn-square">Grun</button>
<button type="button" style="background-color:#FFB24A" class="btn btn-default btn-square">Orange</button>
<button type="button" style="background-color:#FFFD5E" class="btn btn-default btn-square">Gelb</button>
</div>
</div>
Using bootstrap3
With bootstrap3 you have to use col-offset class to align 5 elements in a row.
Fiddle Link
What you want is custom. The only question is: do you want this change in columns widths to apply to all pages/columns or to a particular section of your site?
For site-wide changing number of columns, go to https://getbootstrap.com/docs/3.3/customize/#grid-system, change 12 to 10 and download the result.
If you only want it applying on a particular section, first of all add a .row between .container and .col-*-* (it's quite important). Secondly, add a class to your .row, to distinguish it from other .rows in your website. For this example, I used the class 10-cols:
And add this to your CSS, to override the width of those cols:
.\31\30-cols > * {
width: 50%;
}
#media (min-width: 992px) {
.\31\30-cols > * {
width: 20%;
}
}
However, there still seems to be a logical problem. You say you want the buttons divided as: 5 x 4 on large and 2 x 10 on small. Great. Let's take the contents of each of your columns from large and arrange them nicely in two columns on mobile. We put first, third, and fifth columns on left and second and fourth on right. But you want the contents of 5th to be divided in both columns, right?
So you probably want to put all your buttons inside one single element and either use flexbox or CSS columns to display them as you want.
So you need to display this column as full width on mobile and further divide its contents in two columns:
.\31\30-cols > [class^="col-md"] {
width: 50%;
}
.\31\30-cols > .col-xs-12 {
width: 100%;
}
#media (min-width: 992px) {
.\31\30-cols > [class^="col-md"] {
width: 20%;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="container">
<div class="row 10-cols">
<div class="col-md-12 col-xs-6">
<button type="button" style="background-color:white" class="btn btn-block btn-default btn-square">white</button>
<button type="button" style="background-color:#F7F6E4" class="btn btn-block btn-default btn-square">Beige</button>
<button type="button" style="background-color:#3BA6F8" class="btn btn-block btn-default btn-square">Blau</button>
<button type="button" style="background-color:#F36660" class="btn btn-block btn-default btn-square">Rot</button>
</div>
<div class="col-md-12 col-xs-6">
<button type="button" style="background-color:#FDFCEA" class="btn btn-block btn-default btn-square">Creme</button>
<button type="button" style="background-color:#DBDBDB" class="btn btn-block btn-default btn-square">Graue</button>
<button type="button" style="background-color:#E6C08E" class="btn btn-block btn-default btn-square">Eiche</button>
<button type="button" style="background-color:#358B9F" class="btn btn-block btn-default btn-square">Petrol</button>
</div>
<div class="col-md-12 col-xs-6">
<button type="button" style="background-color:#FF7ECD" class="btn btn-block btn-default btn-square">Rosa</button>
<button type="button" style="background-color:#C9C9C9" class="btn btn-block btn-default btn-square">Silber</button>
<button type="button" style="background-color:#505558;color:white;" class="btn btn-block btn-default btn-square">Anthrazit</button>
<button type="button" style="background-color:C39881" class="btn btn-block btn-default btn-square">Taupe</button>
</div>
<div class="col-md-12 col-xs-6">
<button type="button" style="background-color:#569A9E" class="btn btn-block btn-default btn-square">Trukis</button>
<button type="button" style="background-color:#A03A97" class="btn btn-block btn-default btn-square">Lila</button>
<button type="button" style="background-color:#FFDB53" class="btn btn-block btn-default btn-square">Gold</button>
<button type="button" style="background-color:#2E2E2E;color:white;" class="btn btn-block btn-default btn-square">Schwarz</button>
</div>
<div class="col-md-12 col-xs-12">
<div class="row">
<div class="col-xs-6 col-md-12">
<button type="button" style="background-color:#A16340" class="btn btn-block btn-default btn-square">Braun</button>
<button type="button" style="background-color:#C9DDA8" class="btn btn-block btn-default btn-square">Grun</button>
</div>
<div class="col-xs-6 col-md-12">
<button type="button" style="background-color:#FFB24A" class="btn btn-block btn-default btn-square">Orange</button>
<button type="button" style="background-color:#FFFD5E" class="btn btn-block btn-default btn-square">Gelb</button>
</div>
</div>
</div>
</div>
</div>
As a side-note, given the order of the buttons is not really important, the sane method here would have been to put all the buttons in one column and arrange them using either flexbox:
.\31\30-cols .col-xs-12 {
display: flex;
flex-wrap: wrap;
}
.\31\30-cols .col-xs-12 .btn {
flex: 1 0 calc(50% - 20px);
margin: 5px;
}
#media (min-width: 992px) {
.\31\30-cols .col-xs-12 .btn {
flex-basis: calc(20% - 10px);
}
}
.\31\30-cols .col-xs-12 {
display: flex;
flex-wrap: wrap;
}
.\31\30-cols .col-xs-12 .btn {
flex: 1 0 calc(50% - 20px);
margin: 5px;
}
#media (min-width: 992px) {
.\31\30-cols .col-xs-12 .btn {
flex-basis: calc(20% - 10px);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="container">
<div class="row 10-cols">
<div class="col-xs-12">
<button type="button" style="background-color:white" class="btn btn-block btn-default btn-square">white</button>
<button type="button" style="background-color:#F7F6E4" class="btn btn-block btn-default btn-square">Beige</button>
<button type="button" style="background-color:#3BA6F8" class="btn btn-block btn-default btn-square">Blau</button>
<button type="button" style="background-color:#F36660" class="btn btn-block btn-default btn-square">Rot</button>
<button type="button" style="background-color:#FDFCEA" class="btn btn-block btn-default btn-square">Creme</button>
<button type="button" style="background-color:#DBDBDB" class="btn btn-block btn-default btn-square">Graue</button>
<button type="button" style="background-color:#E6C08E" class="btn btn-block btn-default btn-square">Eiche</button>
<button type="button" style="background-color:#358B9F" class="btn btn-block btn-default btn-square">Petrol</button>
<button type="button" style="background-color:#FF7ECD" class="btn btn-block btn-default btn-square">Rosa</button>
<button type="button" style="background-color:#C9C9C9" class="btn btn-block btn-default btn-square">Silber</button>
<button type="button" style="background-color:#505558;color:white;" class="btn btn-block btn-default btn-square">Anthrazit</button>
<button type="button" style="background-color:C39881" class="btn btn-block btn-default btn-square">Taupe</button>
<button type="button" style="background-color:#569A9E" class="btn btn-block btn-default btn-square">Trukis</button>
<button type="button" style="background-color:#A03A97" class="btn btn-block btn-default btn-square">Lila</button>
<button type="button" style="background-color:#FFDB53" class="btn btn-block btn-default btn-square">Gold</button>
<button type="button" style="background-color:#2E2E2E;color:white;" class="btn btn-block btn-default btn-square">Schwarz</button>
<button type="button" style="background-color:#A16340" class="btn btn-block btn-default btn-square">Braun</button>
<button type="button" style="background-color:#C9DDA8" class="btn btn-block btn-default btn-square">Grun</button>
<button type="button" style="background-color:#FFB24A" class="btn btn-block btn-default btn-square">Orange</button>
<button type="button" style="background-color:#FFFD5E" class="btn btn-block btn-default btn-square">Gelb</button>
</div>
</div>
</div>
or CSS columns:
.\31\30-cols .col-xs-12 {
columns: 2;
column-gap: 10px;
}
#media (min-width: 992px) {
.\31\30-cols .col-xs-12 {
columns: 5;
}
}
.\31\30-cols .col-xs-12 {
columns: 2;
column-gap: 10px;
}
#media (min-width: 992px) {
.\31\30-cols .col-xs-12 {
columns: 5;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="container">
<div class="row 10-cols">
<div class="col-xs-12">
<button type="button" style="background-color:white" class="btn btn-block btn-default btn-square">white</button>
<button type="button" style="background-color:#F7F6E4" class="btn btn-block btn-default btn-square">Beige</button>
<button type="button" style="background-color:#3BA6F8" class="btn btn-block btn-default btn-square">Blau</button>
<button type="button" style="background-color:#F36660" class="btn btn-block btn-default btn-square">Rot</button>
<button type="button" style="background-color:#FDFCEA" class="btn btn-block btn-default btn-square">Creme</button>
<button type="button" style="background-color:#DBDBDB" class="btn btn-block btn-default btn-square">Graue</button>
<button type="button" style="background-color:#E6C08E" class="btn btn-block btn-default btn-square">Eiche</button>
<button type="button" style="background-color:#358B9F" class="btn btn-block btn-default btn-square">Petrol</button>
<button type="button" style="background-color:#FF7ECD" class="btn btn-block btn-default btn-square">Rosa</button>
<button type="button" style="background-color:#C9C9C9" class="btn btn-block btn-default btn-square">Silber</button>
<button type="button" style="background-color:#505558;color:white;" class="btn btn-block btn-default btn-square">Anthrazit</button>
<button type="button" style="background-color:C39881" class="btn btn-block btn-default btn-square">Taupe</button>
<button type="button" style="background-color:#569A9E" class="btn btn-block btn-default btn-square">Trukis</button>
<button type="button" style="background-color:#A03A97" class="btn btn-block btn-default btn-square">Lila</button>
<button type="button" style="background-color:#FFDB53" class="btn btn-block btn-default btn-square">Gold</button>
<button type="button" style="background-color:#2E2E2E;color:white;" class="btn btn-block btn-default btn-square">Schwarz</button>
<button type="button" style="background-color:#A16340" class="btn btn-block btn-default btn-square">Braun</button>
<button type="button" style="background-color:#C9DDA8" class="btn btn-block btn-default btn-square">Grun</button>
<button type="button" style="background-color:#FFB24A" class="btn btn-block btn-default btn-square">Orange</button>
<button type="button" style="background-color:#FFFD5E" class="btn btn-block btn-default btn-square">Gelb</button>
</div>
</div>
</div>

Space between buttons with bootstrap class

I have a problem with three buttons on my site.
I would like to have some space between those buttons.
Is it possible to do this, without using inline styling?
Perhaps bootstrap has some classes for this?
I know I can simply do it with:
style='margin-right:5px;'
or write custom class with this property.
I am just wondering if bootstrap has some classes for this?
Here is example.
Problem is with this three buttons:
<button type="button" class="btn btn-primary col-sm-1">1/2</button>
<button type="button" class="btn btn-primary col-sm-1">1/2</button>
<button type="button" class="btn btn-primary col-sm-1">1/2</button>
Try to put them inside btn-toolbar or some other container.
<div class="btn-toolbar">
<button type="button" class="btn btn-primary col-sm-1">1/2</button>
<button type="button" class="btn btn-primary col-sm-1">1/2</button>
<button type="button" class="btn btn-primary col-sm-1">1/2</button>
</div>
Yes you have to wrap them
<div class="btn-group">
<button type="button" class="btn btn-primary">1/2</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-primary">1/2</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-primary">1/2</button>
</div>
EDITED CODEPEN
<div class="btn-toolbar">
<button type="button" class="btn btn-primary col-sm-1">1/2</button>
<button type="button" class="btn btn-primary col-sm-1">1/2</button>
<button type="button" class="btn btn-primary col-sm-1">1/2</button>
</div>
d-flex justify-content-between
<div class="col-md-3 mt-4 d-flex justify-content-betweend-flex justify-content-between">
<button type="submit" class="btn btn-info text-light" id="atndanceFilter"> <i class="fa fa-search"></i> Filter Report</button>
Reset
</div>
Will work like magic.

Btn-group not stretching width of table

I have a table with a table header and a table row. The header is a btn-group, with 12 buttons to resemble months of a calendar, the row is of 31 columns. I want the btn-group to distribute evenly & stretch the full width of the table row. I can add style="width:100px;" to each button, but that's not responsive, and I don't necessarily know the width of the full table.
Can anyone see what I need to add to my code?
<thead>
<tr>
<th colspan="31">
<div class="btn-toolbar" role="toolbar">
<div class="btn-group">
<button type="button" class="btn btn-default">Jan</button>
<button type="button" class="btn btn-default">Feb</button>
<button type="button" class="btn btn-default">Mar</button>
<button type="button" class="btn btn-default active">Apr</button>
<button type="button" class="btn btn-default">May</button>
<button type="button" class="btn btn-default">Jun</button>
<button type="button" class="btn btn-default">Jul</button>
<button type="button" class="btn btn-default">Aug</button>
<button type="button" class="btn btn-default">Sep</button>
<button type="button" class="btn btn-default">Oct</button>
<button type="button" class="btn btn-default">Nov</button>
<button type="button" class="btn btn-default">Dec</button>
</div>
</div>
</th>
</tr>
</thead>
Here is the css tag I changed from the Bootstrap 3 defaults:
.btn-group {
width:100%;
}
.btn-toolbar {
width:100%;
}
If I use btn-group-justified, it looks like this:
Add the following class to the parent container: .btn-group-justified
<thead>
<tr>
<th colspan="31">
<div class="btn-toolbar" role="toolbar">
<div class="btn-group btn-group-justified">
<button type="button" class="btn btn-default">Jan</button>
<button type="button" class="btn btn-default">Feb</button>
<button type="button" class="btn btn-default">Mar</button>
<button type="button" class="btn btn-default active">Apr</button>
<button type="button" class="btn btn-default">May</button>
<button type="button" class="btn btn-default">Jun</button>
<button type="button" class="btn btn-default">Jul</button>
<button type="button" class="btn btn-default">Aug</button>
<button type="button" class="btn btn-default">Sep</button>
<button type="button" class="btn btn-default">Oct</button>
<button type="button" class="btn btn-default">Nov</button>
<button type="button" class="btn btn-default">Dec</button>
</div>
</div>
</th>
</tr>
and for even more reference, read the following part of the documentation:
http://getbootstrap.com/components/#btn-groups-justified