Kitsakorn P
Kitsakorn P

Reputation: 111

How to resize text box input between mobile and desktop [Bootstrap]

Hello I'm using simple bootstrap textbox like this<input type="text" class="form-control" id="InputFirstName" placeholder="Firstname"id="txtFN" name="txtFN"> It works well on mobile, the text box has 100% width but it has 100% width on my desktop screen too, I don't want it to be 100% width on desktop. How do I customise it for desktop ? do I have to make 2 pages file ? one for mobile and one for desktop. Thanks.

Upvotes: 1

Views: 3946

Answers (3)

Rachel S
Rachel S

Reputation: 3920

By default on mobile the inputs are 100% width. For desktop you can set it to 50% width, for example, or even a pixel value like 250px;

Upvotes: 0

Ani Menon
Ani Menon

Reputation: 28209

Grid sizes :

  • small grid (≥ 768px) = .col-sm-*
  • medium grid (≥ 992px) = .col-md-*
  • large grid (≥ 1200px) = .col-lg-* ...

where,

md - starting at desktops and scaling to large desktops
xs - mobiles
sm - tablets
...

Example Snippet: (Mixed - mobile & desktop example)

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="container-fluid">
  <h1>Hello World!</h1>
  <p>Resize the browser window to see the effect.</p>
  <div class="row">
    <div class="col-xs-9 col-md-7" style="background-color:red;">.col-xs-9 .col-md-7</div>
    <div class="col-xs-3 col-md-5" style="background-color:lavender;">.col-xs-3 .col-md-5</div>
  </div>
  <div class="row">
    <div class="col-xs-6 col-md-10" style="background-color:lavenderblush;">.col-xs-6 .col-md-10</div>
    <div class="col-xs-6 col-md-2" style="background-color:lightgrey;">.col-xs-6 .col-md-2</div>
  </div>
  <div class="row" style="background-color:lightcyan;">
    <div class="col-xs-6">.col-xs-6</div>
    <div class="col-xs-6">.col-xs-6</div>
  </div>
</div>

Refer :

bootstrap grids

read

What is sm,md,lg, ..

Upvotes: 1

Uzbekjon
Uzbekjon

Reputation: 11813

You should wrap it into a .row and .col-* blocks and specify how you want them to be in different sizes:

<div class="row">
  <div class="col-md-6 col-xs-12">

    <input type="text" class="form-control" id="InputFirstName" placeholder="Firstname" id="txtFN" name="txtFN">

    <!-- You can put the whole form here -->

  </div>
</div>

Learn more about what classes to set (col-md-*, col-sm-*, etc.) in the docs.

Upvotes: 2

Related Questions