Bootstrap input group with Mathjax - css

When adding a MathJax formular to a Bootstrap v4 input group, the elements are not align correctly. There is a small step between the label and the input.
<link href="https://rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<div class="row">
<div class="col-md-12">
<p>Without Mathjax everything works fine</p>
<div class="input-group">
<span class="input-group-addon">X1</span>
<input type="number" class="form-control">
</div>
</div>
<div class="col-md-12">
<p>With Mathjax there is a step at the bottom</p>
<div class="input-group">
<span class="input-group-addon">\( x_1 \)</span>
<input type="number" class="form-control">
</div>
</div>
</div>
Edit: This problem occurs with Chrome and a zoom level of 90% and 125% or greater.

Related

How can i decrease boostrap's form-control width without using the responsivness

I have this html
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="form-control-label" for="salary" name="salary">Specify the salary for <span
class="user-detail">{{user?.first_name}}</span></label>
<input id="salary" class="form-control form-control-alternative" type="text">
</div>
</div>
</div>
</div>
when I apply form-control then the input goes till the end of the parent container.
Here I will need to write numbers on the input so it will be too big.
How can I decrease its size ?
If I try to apply custom style
.form-control {
width:200px !important;
}
then it starts to be inline-block instead like block element.
You can use Bootstrap's column sizing on form controls. Here I'm using col-* for various sizes.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="form-group">
<label class="form-control-label" for="salary" name="salary">Specify the salary for <span
class="user-detail">{{user?.first_name}}</span></label>
<input id="salary" class="form-control form-control-alternative col-4" type="text">
</div>
<div class="form-group">
<label class="form-control-label" for="salary" name="salary">Specify the salary for <span
class="user-detail">{{user?.first_name}}</span></label>
<input id="salary" class="form-control form-control-alternative col-6" type="text">
</div>
<div class="form-group">
<label class="form-control-label" for="salary" name="salary">Specify the salary for <span
class="user-detail">{{user?.first_name}}</span></label>
<input id="salary" class="form-control form-control-alternative col-8" type="text">
</div>
</div>
</div>
</div>
See Bootstrap's column sizing docs.

How to append multiple form-controls (bootstrap 3)

I would like to connect multiple text inputs with the same layout as connecting text-inputs with appends. However, I am not sure how to do that. As per docs, it is only possible to append a button or text to a text-input:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
<div class="input-group">
<label class="input-group-addon">
<input type="checkbox">
</label>
<input type="text" class="form-control">
</div>
</div>
</div>
</div>
However, I would like to connect 2 text-inputs. But when I try, the inputs start stacking instead of beeing displayed next to eachother:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
<div class="input-group">
<label class="input-group-addon">
<input type="checkbox">
</label>
<input type="text" class="form-control">
<input type="text" class="form-control">
</div>
</div>
</div>
</div>
How can I achieve what I want?
You have to change the width property of class .input-group .form-control to auto. It's currently 100%. That's why the input is taking the entire space.
Note: This will override the default behaviour, so you may add custom class name and then modify, if you want to avoid default modification.

Bootstrap input-group -> input with addon & help text, addon height?

I have a HTML input.
The small help text i populate with Jquery.
My problem is that the input-group-addon height will stretch all way down to the smallelement. I´d like it to be as high as the input.
How can i solve this?
<div class="input-group">
<div class="input-group-addon">Obj. Nr</div>
<input type="text" class="form-control">
<small class="form-text text-muted"></small>
</div>
Just add small element after input
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-sm-6">
<div class="input-group">
<div class="input-group-addon">Obj. Nr</div>
<input type="text" class="form-control">
</div>
<small class="form-text text-muted">Small element</small>
</div>

Bootstrap resizing input & text(right of input)

I'm stuck for a while on a scaling problem ...
When i resize the window(mobile) the "%" go below the input even with the 80% width, idk why he don't stay at right...
<html>
<head>
<!--<link href="../bootstrap/css/bootstrap.css" rel="stylesheet">-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<head>
<body>
<div class="col-md-6">
<div class="row form-inline text-center">
<div class="form-group col-md-3 form-inline text-center">
<label for="a">A</label></br>
<input id="a" name="a" type="number" class="form-control" style="width:80%;"/><b>%</b>
</div>
<div class="form-group col-md-3">
<label for="b">B</label></br>
<input id="b" name="b" type="number" class="form-control" style="width:80%"/> <b>%</b>
</div>
<div class="form-group col-md-3">
<label for="c">C</label></br>
<input id="c" name="c" type="number" class="form-control" style="width:80%"/> <b>%</b>
</div>
<div class="form-group col-md-3">
<label for="c">D</label> </br>
<input id="c" name="c" type="number" class="form-control" style="width:80%"/> <b>%</b>
</div>
</div>
</div>
<body>
</html>
if anyone knows what's wrong ...
The '%' is taking up more then 20% of the width on small screens. A nice solution would be to use input addons available in bootstrap: http://getbootstrap.com/components/#input-groups-basic

HTML DIV height in IE

Here is a small piece of HTML.
<html>
<body>
<div id="containerDiv" style="background-color:red; height: 200px">
<div id="topDiv" style="background-color:green">
<input type="button">1</input>
<div>
<div id="textAreaDiv" style="background-color:blue;width:100%; height:100%;">
<textarea style="width:100%; height:100%;">123</textarea>
</div>
<div id="bottomDiv" style="background-color:purple">
<input type="radio" name="Milk" value="Milk">Milk</input>
<input type="radio" name="Butter" value="Butter">Butter</input>
</div>
</div>
</body>
</html>
What I am trying to do it to make textAreaDiv.height be containerDiv.height - (topDiv.height + bottomDiv.height). This works perfectly in Chrome, but not in IE9. In IE9 the textarea's height is about two character's height. Any idea how to get this to work in IE9 the same as in Chrome?
Here is a screen cap of what I am getting:
http://postimage.org/image/bfn6bsalv/
UPDATE
Here is a solution with javascript, but I would still like a purely CSS solution
<html>
<head>
<script type="text/javascript" src="JQuery-1.7.2.min.js"></script>
</head>
<body>
<script>
$(document).ready(function() {
var textHeight = $('#containerDiv').height() - ($('#topDiv').height() + $('#bottomDiv').height());
$('#textBox').height(textHeight);
});
</script>
<div id="containerDiv" style="background-color:red; height: 400px">
<div id="topDiv" style="background-color:green;height:25px;">
<input type="button">1</input>
</div>
<div id="textAreaDiv" style="background-color:blue;width:100%;">
<textarea id="textBox" style="width:100%;">123</textarea>
</div>
<div id="bottomDiv" style="background-color:purple;height:25px;">
<input type="radio" name="Milk" value="Milk">Milk</input>
<input type="radio" name="Butter" value="Butter">Butter</input>
</div>
</div>
</body>
</html>
I'm glad you found something that worked. I wanted to let you know I see why it didn't work. Your code isn't valid. The closing tag for topdiv is missing the forward slash.

Resources