Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change <input type=text> font-size without changing its width

Tags:

html

css

flexbox

I have two text-boxes whose ratio of width is supposed to be 2:1, I can do that using flex. But when I change the font-size to 300% the width of the text boxes becomes equal.
How do I avoid that and keep the width in the ratio 2:1?

Here's the Code:

input[type=text] {
  font-size: 300%;
}
#b4 {
  flex: 2;
}
#b2 {
  flex: 1;
}
div {
  display: flex;
  width: 100%;
}
<div>
  <input type="text" id="b4"></input>
  <input type="text" id="b2"></input>
</div>

Also, I don't want to set fixed width to any text-box.

like image 449
Mahesh Bansod Avatar asked Sep 17 '15 08:09

Mahesh Bansod


1 Answers

This is a Firefox issue.

The best solution is adding a min-width for the input.

input{ min-width:0;}

OR

wrap the individual inputs in divs and flex those and set the inputs to be 100% wide.

like image 160
Abhiman Ranaweera Avatar answered Sep 30 '22 18:09

Abhiman Ranaweera