Remove white space from table cell - html

I have the following table:
<table>
...
<td>
<div class="btn-group btn-group-sm">
<button class="btn btn-info mini"><span class="glyphicon glyphicon-duplicate"></span></button>
<button class="btn btn-default mini">09:00</button>
<button class="btn btn-default mini">09:30</button>
<button class="btn btn-default mini">10:00</button>
<button class="btn btn-default mini">10:30</button>
<button class="btn btn-default mini">11:00</button>
<button class="btn btn-default btn-block chev down"><span class="glyphicon glyphicon-chevron-down"></span></button>
</div>
</td>
jsfiddle
And I want to remove the extra space next to my button-group so that there's little margin on either side. Each button has a fixed width and so does the button group:
CSS:
.btn-group {
width: 117px;
}
.btn-group-sm > .btn.mini {
padding: 5px 3px;
width: 40px;
}
.btn-group > .btn.mini:first-child:not(:last-child):not(.dropdown-toggle) {
border-radius: 0;
}
.btn-group > .btn.mini:first-child {
margin-left: -1px;
}
.btn-group-sm>.btn.mini,
.btn.chev {
border-radius: 0px;
}
.btn.chev {
width: 118px;
}
I've already tried using margin: 0 and trying to fix the column width, but with no luck so far.

On your table there is a padding:5px; you have to overwrite it with the following:
table.table {
width: auto;
margin:0 auto;
}
/** only for the head of the table. */
table.table thead th {
padding:0;
}
/** only for the body of the table. */
table.table tbody td {
padding:0;
}
Make sure you place this CSS after the CSS of Bootstrap! Additonaly remove all classes on the th (named col-md-1). The space should be removed like this example: https://jsfiddle.net/sebastianbrosch/3obsbh5n/2/

There appears to be a padding of 5px tied to table-condensed tbody>tr>td in the Bootstrap CSS. You can override this with your own style is several ways. A simple example would be to add a class to some td elements where you are going to have buttons:
<td class="buttonCell">
And override the Bootstrap style by using something like this:
.table-condensed tbody>tr>td.buttonCell {
padding: 0px;
}

Related

Is it possible to have button text in two lines with different fonts using HTML and CSS?

Using the attribute value in HTML, I can't make button text work in two lines as well as different font sizes
I have already tried whitespace in css but it's more like word wrap and that does not solve my problem. I also tried using ampersand-hash13; and ampersand-hash10; but it doesn't work as well.
#media (min-height: 280px) {
.divNumKeypad {
position: fixed;
bottom: 0;
width: 100%;
}
.numberBtn{
font-size: 30px;
height: 68px;
}
<div class="col-xs-4 ">
<input id="btnEight" type="button" tabindex="-1" value="HI HELLO" class="btn btn-primary btn-block numberBtn" onclick="buttonClick(8)" />
</div>
I expect to have a button with two lines of text. "HI" should be on the first line with bigger font and the bottom text "HELLO" should be smaller than the text on the top.
Try this below
#media (min-height: 280px) {
.line-1, {
display:block;
font-size: 20px
}
.line-2 {
display: block;
font-size: 10px;
}
}
<div class="col-xs-4 ">
<button>
<span class="line-1">HI</span>
<span class="line-2">HELLO</span>
</button>
</div>
Consider using button instead of input:
button {
font-size: 30px;
}
<button>HI<br><small>HELLO</small></button>
Try this.
label{
max-width: 150px;
font-size: 18px;
display: block;
padding:10px 20px;
border:1px solid black;
cursor: pointer;
}
label span{
display: block;
font-size: 14px;
}
label input{
background:none;
border:none;
}
input[value]{
font-size: 0;
display: none;
}
<div class="col-xs-4 ">
<label> <input id="btnEight" type="button" tabindex="-1" value="HI HELLO" class="btn btn-primary btn-block numberBtn" onclick="buttonClick(8)" />HI<span> HELLO</span></label>
</div>

How to force two buttons into one line

Below you see the cell where the buttons (bootstrap 4) are. The other cells were not printed. The EDIT and DELETE button are one over the other (2 lines). How to force them to the same line?
<div class="container">
<table class="table table-striped">
..deleted...
<tbody>
..deleted...
<tr>
<div>
<form method="GET">
{% csrf_token %}
<button class="btn btn-outline-secondary btn-sm" type="submit" name="edit"
value={{objekt.id}}>Edit</button>
</form>
<div id="colwrap">
<form method="POST">
{% csrf_token %}
<button class="btn btn-outline-secondary btn-sm" type="submit" name="delete"
value={{objekt.id}}>Delete</button>
</form>
</div>
</div>
</tr>
</tbody>
</table>
</div class="container">
I finally found an answer (https://www.w3schools.com/howto/howto_css_button_group.asp) (with additional CSS).
In the html:
<div class="btn-group">
<button>Apple</button>
<button>Samsung</button>
<button>Sony</button>
</div>
In the CSS (in my case in APPfolder/static/app.css):
.btn-group button {
background-color: #4CAF50; /* Green background */
border: 1px solid green; /* Green border */
color: white; /* White text */
padding: 10px 24px; /* Some padding */
cursor: pointer; /* Pointer/hand icon */
float: left; /* Float the buttons side by side */
}
.btn-group button:not(:last-child) {
border-right: none; /* Prevent double borders */
}
/* Clear floats (clearfix hack) */
.btn-group:after {
content: "";
clear: both;
display: table;
}
/* Add a background color on hover */
.btn-group button:hover {
background-color: #3e8e41;
}

How to set width of a button bootstrap

How to set custom width of a bootstrap button.
My problem is that I don't know how to shrink width of button to like on the image (it's a submit button). Left part is input text. My problem is button is too wide. Here is the code:
<div class="col-xs-5 col-xs-offset-3">
<div class="input-group input-group-lg">
<input type="text" class="form-control input-lg input-forme" id="Text" placeholder="Text">
<span class="input-group-btn tipka">
<button type="submit" class="btn btn-group-small" id="form-submit">Submit</button>
</span>
</div>
</div>
You can change width and padding : https://jsfiddle.net/wz8ac5d4/
.btn {
width:0px;
padding:5px;
}
Also you can add a class to your btn, it is a better practice.
HTML:
<button type="submit" class="btn btn-group-small my-small-btn" id="form-submit">Submit</button>
CSS :
.my-small-btn {
width:0px;
padding:5px;
}
The classes that define the different sizes are:
.btn-lg
.btn-md
.btn-sm
.btn-xs
refer this link
http://www.w3schools.com/bootstrap/bootstrap_buttons.asp
You can increase its size with this:
.btn {
width: 100%;
padding: 5px;
}
I used max-width with padding.
HTML
<button type="submit" class="btn custom-btn" id="form-submit">Submit</button>
CSS
.custom-btn {
max-width: 100%;
padding-left:25px;
padding-right:25px;
}
You can also just shortcut the padding.
.custom-btn {
max-width: 100%;
padding: 6px 25px;
}
Just adjust the 25px to whatever length you want to get the appropriate size.
Please note that 6px is the standard top and bottom padding for a medium bootstrap button. You will have to adjust accordingly for large and small buttons.

Float multiple <button> elements in the same direction, with correct order

I have a group of buttons:
<div class="row">
<button type="button" class="btn btn-warning btn-lg clearButton" onclick="resetSignature();"> Reset </button>
<button type="button" class="btn btn-warning btn-lg skipButton" onclick="skipQuestion();">Skip Question</button>
<button type="button" class="btn btn-success btn-lg nextQuestionButton" onclick="goToNextQuestion();"> Next Question → </button>
</div>
(I am using bootstrap). And I have some css:
.nextQuestionButton, .skipButton {
float: right;
margin: 5px 5px 5px 5px;
width: auto;
font-size:16px;
}
.clearButton {
float: left;
margin: 5px 5px 5px 5px;
font-size: 16px;
width: auto;
}
#media screen and (max-width: 500px) {
.clearButton, .skipButton, .nextQuestionButton {
width: 100%;
float: none;
}
}
This generates output like so:
My problem is that I want the green button to be the farthest to the right on a wide screen, and the bottom button on a narrow screen. I tried re-ordering the buttons (among other things), but then it ruined the order on narrow screens. How can I get the green button to line up on the right of the yellow one?
EDIT: Here is a jsFiddle
See this fiddle
I've changed your HTML a little bit
<div class="row">
<button type="button" class="btn btn-warning btn-lg clearButton" onclick="resetSignature();">Reset</button>
<div class="pull-right">
<button type="button" class="btn btn-warning btn-lg skipButton" onclick="skipQuestion();">Skip Question</button>
<button type="button" class="btn btn-success btn-lg nextQuestionButton" onclick="goToNextQuestion();">Next Question →</button>
</div>
</div>
and your CSS as
.nextQuestionButton, .skipButton {
margin: 5px 5px 5px 5px;
width: auto;
font-size:16px;
}
.clearButton {
float: left;
margin: 5px 5px 5px 5px;
font-size: 16px;
width: auto;
}
#media screen and (max-width: 500px) {
.clearButton, .skipButton, .nextQuestionButton {
width: 100%;
float: none;
}
}
What I have done is that, i enclosed two of your buttons in a div which is floated right instead of the buttons. To float right the div, I used the bootstrap class pull-right.
UPDATE
See the updated fiddle
.green {
float:left;
}
#media screen and (max-width: 300px) {
.green {float:right;}
}
just float it in different collection when screen is small.

Window resizing causes text to overflow bootstrap button boundaries or button spills out of div area

Buttons are fine until I resize window to be very small or in my case, look at the site on a small screen device such as mobile phone.
I want two different scenarios. One in which an area holds buttons that are equal in width but then when I size the window down the contents of the button spill out of the button.
I also want another area that has buttons that adjust to the size of the text. In this scenario, the text does not spill out of the buttons but now the buttons are spilling out of the div area.
I was trying everything I could think of which is why one area uses and the other uses <button></button>
Both scenarios are in the fiddle http://jsfiddle.net/leopardy/VFNmC/
The code from the fiddle:
html
<div class="combo">
<div id="button-area-1">
<div>txt <span class="glyphicon glyphicon-circle-arrow-right"></span></div>
<div>txt txt <span class="glyphicon glyphicon-circle-arrow-right"></span></div>
<div>txt txt txt <span class="glyphicon glyphicon-circle-arrow-right"></span></div>
<div>txt txt txt txt <span class="glyphicon glyphicon-circle-arrow-right"></span></div>
</div>
<div id="button-area-2">
<button type="button" class="btn btn-default btn-xs btn-has-width">hi<span class="glyphicon glyphicon-circle-arrow-right"></span></button>
<button type="button" class="btn btn-default btn-xs btn-has-width">hi hi<span class="glyphicon glyphicon-circle-arrow-right"></span></button>
<button type="button" class="btn btn-default btn-xs btn-has-width">hi hi hi<span class="glyphicon glyphicon-circle-arrow-right"></span></button>
<button type="button" class="btn btn-default btn-xs btn-has-width">hi hi hi hi<span class="glyphicon glyphicon-circle-arrow-right"></span></button>
</div>
</div>
css
.combo {
position: relative;
width: 100%;
height: 400px;
background-color: blue;
}
#button-area-1 {
position:absolute;
top:40%;
left:60%;
z-index: 2;
background-color: #606060;
background-color: rgba(96,96,96,0.5);
border: 1px solid grey;
outline: 1px solid darkgrey;
width: 30%;
padding-top: 1%;
padding-bottom: 1%;
}
#button-area-2 {
position:absolute;
top:5%;
left:60%;
z-index: 2;
background-color: #medium-gray;
background-color: rgba(96,96,96,0.5);
border: 1px solid grey;
outline: 1px solid darkgrey;
width: 30%;
padding-top: 1%;
padding-bottom: 1%;
}
.btn-no-width {
margin-top:1%;
margin-left: 10%;
margin-right: 10%;
-webkit-font-smoothing: antialiased;
background-repeat: repeat-x;
}
.btn-has-width {
width: 80%;
margin-top:1%;
margin-left: 10%;
margin-right: 10%;
-webkit-font-smoothing: antialiased;
background-repeat: repeat-x;
}
You need to set min-width(150px should do for your example) for #button-area-1 and #button-area-2. But keep in mind this doesn't work on IE6 or less (not like it's still in use).