Search code examples
cssstylesheet

Changing width of textbox using css


I have css class like this:

.new-fld input[type="text"]{width:418px !important; margin-bottom:0px !important; height:18px !important; background-color:transparent !important; color:#FFF !important; border-bottom:1px solid #FFF; border-left:none !important; border-right:none !important; border-top:none !important; font-size:14px; /*padding:0 8px;*/}

It is applied to all the input filds on page.

I want some fields length to be different so I created another class like this

 .new-fld input[type="text"]{width:45px !important; margin-bottom:0px !important; height:18px !important; background-color:transparent !important; color:#FFF !important; border-bottom:1px solid #FFF; border-left:none !important; border-right:none !important; border-top:none !important; font-size:14px; /*padding:0 8px;*/}

and applied it like this

   <div class="new-fld">
                                        <input type="text" value="+44 1793 853219" name="">
                                          <input type="text" value="+ 44" readonly="readonly" name="Dialprefix1" id="Dialprefix1" class="dialprefix" style="text-align:right;width:45px;">

                                        <span>*</span>                                        
                                        </div>

As you can see, I entered width in textbox style but still it is not working.

but It is not working. Please suggest me good solution to it.


Solution

  • use

     <input type="text" value="+ 44" readonly="readonly" name="Dialprefix1" id="Dialprefix1" class="dialprefix" style="text-align:right" size='10' />
    

    and check the result.

    OK, this will solve your problem (but I hope had a good reason to add !important to all styles):

    <input type="text" value="+ 44" readonly="readonly" name="Dialprefix1" id="Dialprefix1" class="dialprefix" style="text-align:right;width:45px !important;">