Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align text in bootstrap col fields

I have a requirement of displaying name value pairs in html using bootstrap. I am using the class "col-md-1" for name and value columns and so the data is displayed in two columns. The problem is that as bootstrap divides the screen in 12 columns, it leaves much space to the left and right of the content in field values. I tried using the classes "text-left","text-right" but it doesn't seem to work in conjunction with "col-md-" classes. How can one align text to left or right in bootstap columns (say col-md-) without hardcoding left or right in style to certain pixels?

   <div class="row">
      <div class="col-md-1">column1</div>
      <div class="col-md-1"><p class="text-right">Name</p></div>
      <div class="col-md-1"><p class="text-left">Value</p></div>
      <div class="col-md-1">column4</div>
      <div class="col-md-1">column5</div>
      <div class="col-md-1">column6</div>
      <div class="col-md-1">column7</div>
      <div class="col-md-1">column8</div>
      <div class="col-md-1">column9</div>
      <div class="col-md-1">column10</div>
      <div class="col-md-1">column11</div>
      <div class="col-md-1">column12</div>
  </div>
like image 981
Mothupally Avatar asked Oct 15 '25 08:10

Mothupally


2 Answers

Try this:

Use 'row' class , it will avoid padding

 <div class="col-md-1"><p class="row text-right">Name</p></div>
 <div class="col-md-1"><p class="row text-left">Value</p></div> 

DEMO

like image 101
Suganth G Avatar answered Oct 17 '25 23:10

Suganth G


Hope this Help You can use it like following

<div class="col-md-1 text-center">

For Detail have a look at following link Jsfiddle

Any furthur questions are welcomed

Thanks ROHIT

like image 33
Rohit Avatar answered Oct 18 '25 00:10

Rohit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!