2016-08-22 2 views
0

Ich habe eine Tabelle mit Eingabefeldern in der 1. Spalte. Jetzt möchte ich nur die Größe des E-Mail-Eingabefeldes ändern. Aber wenn ich es ändere, nehmen alle Eingabefelder automatisch auch die Größe an. Was muss ich hier ändern?Ändern Sie die Eingabegröße in Spalte

<table > 
     <tbody class="thsize"> 

      <tr class="thsize"> 
       <th class="thsize">First Name</th> 
       <td class="thsize"> 
        <input class="form-control" id="firstName" ngControl="firstName" type="text" [(ngModel)]="webUser.firstName" #firstName="ngForm"> 
       </td> 
       <td class="thsize"></td>   

       <th class="thsize">Last Name</th> 
       <td class="thsize"> 
        <input class="form-control" id="lastName" ngControl="lastName" type="text" [(ngModel)]="webUser.lastName" #lastName="ngForm"> 
       </td> 
      </tr> 

      <tr class="thsize"> 
      <th class="thsize">Email</th> 
       <td class="thsize"> 
        <input style="width:300px;" class="form-control" id="email" ngControl="email" type="text" [(ngModel)]="webUser.email" #email="ngForm"> 
       </td> 
      </tr> 

      <tr class="thsize"> 
       <th class="thsize">Country</th> 
       <td class="thsize"> 
        <input class="form-control" id="country" ngControl="country" type="text" [(ngModel)]="webUser.country" #country="ngForm"> 
       </td> 
       <td class="thsize"></td>   

       <th class="thsize">Language</th> 
       <td class="thsize"> 
        {{webUser.language}} 
       </td> 
      </tr> 

     </tbody> 
    </table> 

wenn ich style="width:300px;" in dem E-Mail-Eingabefeld setzen, alle dann andere Felder in dieser Spalte wird automatisch die Breite = 300

Vielen Dank im Voraus.

+0

Es scheint mir der Grund, dass alle anderen Felder auf Breite 300 ändern, weil Sie 'class =" form-control "' verwenden. Wenn Sie also dieselbe Klasse aufrufen und den Stil inline ändern, überschreiben Sie möglicherweise die Breite, die Sie an der Stelle angegeben haben, an der die Formularsteuerung definiert ist. Macht nichts. @Lalji hat eine bessere Lösung. – Ishnark

+0

Ich verstehe die Tabelle überhaupt nicht. Die Zeilen haben unterschiedliche Spalten. Und warum sind in jeder Zeile Tabellenköpfe definiert? – mm759

Antwort

4

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 

 
<table > 
 
     <tbody class="thsize"> 
 

 
      <tr class="thsize"> 
 
       <th class="thsize">First Name</th> 
 
       <td class="thsize"> 
 
        <input class="form-control" id="firstName" ngControl="firstName" type="text" [(ngModel)]="webUser.firstName" #firstName="ngForm"> 
 
       </td> 
 
       <td class="thsize"></td>   
 

 
       <th class="thsize">Last Name</th> 
 
       <td class="thsize"> 
 
        <input class="form-control" id="lastName" ngControl="lastName" type="text" [(ngModel)]="webUser.lastName" #lastName="ngForm"> 
 
       </td> 
 
      </tr> 
 

 
      <tr class="thsize"> 
 
      <th class="thsize">Email</th> 
 
       <td class="thsize" colspan="4"> 
 
        <input class="form-control" id="email" ngControl="email" type="text" [(ngModel)]="webUser.email" #email="ngForm"> 
 
       </td> 
 
      </tr> 
 

 
      <tr class="thsize"> 
 
       <th class="thsize">Country</th> 
 
       <td class="thsize"> 
 
        <input class="form-control" id="country" ngControl="country" type="text" [(ngModel)]="webUser.country" #country="ngForm"> 
 
       </td> 
 
       <td class="thsize"></td>   
 

 
       <th class="thsize">Language</th> 
 
       <td class="thsize"> 
 
        {{webUser.language}} 
 
       </td> 
 
      </tr> 
 

 
     </tbody> 
 
    </table>

hinzufügen colspan

<td class="thsize" colspan="4"> 
        <input style="width:300px;" class="form-control" id="email" ngControl="email" type="text" [(ngModel)]="webUser.email" #email="ngForm"> 
       </td> 
+0

hat es nicht funktioniert. Jetzt haben alle Spalten eine Breite = 300 – trap

+0

, wenn Sie voll mit dann Breite inline entfernen möchten –

+1

@trap wie Lalji sagte, entfernen Sie style = "width: 300px;" und benutze col-span wie erwähnt! :) –

0

Versuchen Sie, diese

table{width:300px; table-layout:fixed;} 
table tr td,table tr th{width:20%;word-wrap: break-word;} 
table tr td.thsize > input{width:100%;} 

table{width:300px; table-layout:fixed;} 
 
table tr td,table tr th{width:20%;word-wrap: break-word;} 
 
table tr td.thsize > input{width:100%;}
<table > 
 
     <tbody class="thsize"> 
 

 
      <tr class="thsize"> 
 
       <th class="thsize">First Name</th> 
 
       <td class="thsize"> 
 
        <input class="form-control" id="firstName" ngControl="firstName" type="text" [(ngModel)]="webUser.firstName" #firstName="ngForm"> 
 
       </td> 
 
       <td class="thsize"></td>   
 

 
       <th class="thsize">Last Name</th> 
 
       <td class="thsize"> 
 
        <input class="form-control" id="lastName" ngControl="lastName" type="text" [(ngModel)]="webUser.lastName" #lastName="ngForm"> 
 
       </td> 
 
      </tr> 
 

 
      <tr class="thsize"> 
 
      <th class="thsize">Email</th> 
 
       <td class="thsize"> 
 
        <input class="form-control" id="email" ngControl="email" type="text" [(ngModel)]="webUser.email" #email="ngForm"> 
 
       </td> 
 
      </tr> 
 

 
      <tr class="thsize"> 
 
       <th class="thsize">Country</th> 
 
       <td class="thsize"> 
 
        <input class="form-control" id="country" ngControl="country" type="text" [(ngModel)]="webUser.country" #country="ngForm"> 
 
       </td> 
 
       <td class="thsize"></td>   
 

 
       <th class="thsize">Language</th> 
 
       <td class="thsize"> 
 
        {{webUser.language}} 
 
       </td> 
 
      </tr> 
 

 
     </tbody> 
 
    </table>

+0

Wenn Sie Bootstrap verwenden, verwenden Sie die .table-Klasse mit

Verwandte Themen