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.
Related
I want to have these objects in one row
My HTML code looks like this:
<input type="button" class="formreturn" value="Copy Url" onclick="Copy();" />
<label><input type="text" class="txtfilename" id="op-text-filename" placeholder="type file name"/>.txt</label>
<button type="button" class="formreturn" onclick="saveURLtoTXTfile();"><span class="glyphicon glyphicon-download"></span>.TXT</button>
<button class="excelsubmit" onclick="exportData()"><span class="glyphicon glyphicon-download"></span>.CSV</button>
<button id="btnExport" class="excelsubmit" onclick="fnExcelReport();"><span class="glyphicon glyphicon-download"></span>.XLS </button>
and CSS
.formreturn {
font-weight:700;
text-decoration: none;
display:inline-block;
color:black;
background:#c6e2f2;
padding: 9px;
border-radius: 3px;
}
.copyurltext {
font-weight: bold;
margin-left: 30px;
}
.txtfilename {
display: inline-block;
float: left;
padding: 5px;
}
.excelsubmit {
font-weight:700;
float: right;
padding: 8px;
background:#c6e2f2;
}
If I place the float:left in my formreturn, then everything is fine, but the order is wrong, as the .txt button goes next to the "Copy Url" button. I want to have the order as you see below, but with everything lined up properly.
I tried something like here:
http://jsfiddle.net/A9Ap7/1/
codeproject.com/Questions/5280800/How-do-I-put-everything-in-one-line
and here
css everything on same line
but it didn't work for me
How can I fix this?
Try this:
<div class="container">
<div classs="btns-left">
<input type="button" class="formreturn" value="Copy Url" onclick="Copy();" />
<label><input type="text" class="txtfilename" id="op-text-filename" placeholder="type file name"/>.txt</label>
<button type="button" class="formreturn" onclick="saveURLtoTXTfile();"><span class="glyphicon glyphicon-download"></span>.TXT</button>
</div>
<div class="btns-right">
<button class="excelsubmit" onclick="exportData()"><span class="glyphicon glyphicon-download"></span>.CSV</button>
<button id="btnExport" class="excelsubmit" onclick="fnExcelReport();"><span class="glyphicon glyphicon-download"></span>.XLS </button>
</div>
</div>
.container {
display: flex;
justify-content: space-between;
}
.btns-left,
.btns-right {
display: flex;
}
Also, you can use properties for align elements by horizontal axis, as an example align-items: flex-start.
Or:
float: left; for btns-left and float: right; for btns-right and display: inline-block; for every element without display: flex; anywhere.
Also, can try, float for every element without any wrappers (left properties for left side, right ones for right side)
Grid layout, but it's more complicated. The best solution is applying flexbox layout for positioning elements. Better avoid floats, cause it might voke some troubles with clearing flow in future.
Try to give all elements a display: inline-block for starters (so, the button input, label and three buttons), float: left is not recommended and bad practice.
You want it all to be next to each other? Maybe start using css grid, it's useful for making things in line.
Then there's always the option of setting all these things in a navigation bar, so it's always at the top of your screen in line.
Perhaps try and create a container that holds all the buttons in place?
I need to finish simple form, but I'm loosing my mind dealing with CSS, etc. Here is a picture that shows what is wrong
As you can see, Label is position like 1px to the left and button is bigger than input. I'v used same input-group-addon with textarea, using this style
.input-group{
width: 100%;
}
.input-group-addon{
width: 220px !important;
}
.textarea-addon{
border-bottom-left-radius: 0px !important;
border-top-right-radius: 4px !important;
border:1px solid #ccc !important;
border-bottom: none !important;
}
And it works perfect, but using it with text input just looks ugly. Here is the code
<div class="col-sm-12">
<span class="input-group-addon textarea-addon">Account numbers</span>
<div class="input-group input-group-sm form-inline panel">
<input type="text" ng-model="model.accountNumber" id ="accountNumber" class="form-control" style="width:80%"> </input>
<input type="button" ng-click="add(accountNumber)" value="Add" class="btn btn" style="width:20%"></input>
</div>
</div>
Hope this will helpful for you, I have put new class to your code
.inputgroup_flex {
display: flex;
align-items: stretch;
border-width: 0;
}
.inputgroup_flex #accountNumber {
height: 36px;
}
https://codepen.io/Thakur92411/pen/QZLqNZ
I want to reduce default size of button but only the font size reduces. I want to reduce font size and button size in proportion.
I tried to reduce font button then the size was not in proportion to font.
Reference link: https://mdbootstrap.com/components/buttons/
Code:
HTML:
<div class="standings">
<div class="standingstitle">
<h4>Teams Standings</h4>
<button type="button" class="btn btn-danger">See all stats</button>
</div>
</div>
CSS:
.btn-danger{
font-size: 6px;
width: 25px;
height: 30px;
}
Screenshot: (default size of button):
After trying above code gave me:
You need to adjust the padding property in the default btn selector. Try this code.
.btn {
padding: .4rem 1.5rem;
}
Try to make your selector more specific to prevent your rules from being overwritten:
btn btn-sm btn-danger {
font-size: 6px;
width: 25px;
height: 30px;
}
I am trying to achieve the effect as shown in below screenshot using Bootstrap 3.
As you can see, the search button is both:
1) inside the input
2) styled with a glyphicon so as to not appear like a "button".
How can I achieve a similar effect with Bootstrap 3? I would like to place a button with a magnifying glass glyphicon at the end of a text input, however the button keeps appearing below the input as opposed to inside of it.
A wrapper div with position: relative; then positioning the submit button on top using position: absolute;. Like this:
http://jsfiddle.net/VtP5k/
HTML
<form>
<div id="search">
<input type="text" />
<button type="sutmit">Search</button>
</div>
</form>
CSS
#search {
position: relative;
width: 200px;
}
#search input {
width: 194px;
}
#search button {
position: absolute;
top: 0;
right: 0;
margin: 3px 0;
}
Try this.
In bootstrap you have to use button type submit instead of input type;
Both works fine! use button in bootstrap!
div {
padding: 15px;
background: #000;
}
.btn {
text-align: left !important;
font-size: 12px !important;
padding: 20px 12px !important;
width: 200px !important;
color: #888 !important;
}
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet" />
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div>
<button type="submit" class="btn btn-default">
awesomeness <span class="glyphicon glyphicon-search pull-right"></span>
</button>
<div>
Or see this fiddle
<button type="submit" class="btn btn-default">
Awesomeness <span class="glyphicon glyphicon-search"></span>
</button>
The problem is because the button is adhering to the normal flow of html and thus appears below the first element. What you need to do is wrap both the input and search button in an div and then make the search button absolute positioning. Then you can ad some jQuery functionality on a click function to achieve an event is needs be.
<html>
<body>
<div>
<input type="text" value="test"/>
<span id="search" class="absolute">x</span>
</div>
<style>
.absolute {
position:absolute;
top:9px;
left:115px;
}
</style>
<script>
$(document).on('click','#search',function(){
//some functionality
}
</script>
</body>
</html>
I've got two forms inside a larger div. Each form has a button to click on and a text area. I've added divs inside the forms to style the buttons how I like. I want the two buttons to go side by side with their corresponding text areas underneath them. "display:inline:block" does not seem to be doing it for me...
This is what they look like now.
Here is my HTML.
<div class="window">
<form class="sumform" action="#" method="post">
<div class="btns btn_sum">
<input type="submit" id="sub_sum" value="Summary Statistics"/>
</div>
<input type="text" id="sum_spec"/>
</form>
<form class="histform" action="#" method="post">
<div class="btns btn_hist">
<input type="submit" id="sub_hist" value="Histogram"/>
</div>
<input type="text" id="hist_spec"/>
</form>
</div>
Here is my CSS:
.window {
background-color: #fdf2e3;
display: inline-block;
text-align: left;
width:100%;
font-size: 12px;
}
div.btns input {
cursor:pointer;
padding-top:40px;
padding-bottom:60px;
width:130px;
height:0px;
border-radius: 6px;
background-color:#3acb9a;
border: none;
text-align:center;
display:inline-block;
color:#ffffff;
font-size:12px;
}
You can change the display property for your form
form {
display:inline-block;
}
The demo http://jsfiddle.net/TT7BC/3/
Remember it will display side by side if they can fit into his parent width so you can set fixed widths for .window and form or use in parent white-space:nowrap to prevent the items break in a new line