javascript - HTML, CSS, JS - Align textareas with labels in table display -


i using following css align labels , textareas

div     { display: table;      } p       { display: table-row;  } label   { display: table-cell; text-align: center;} textarea{ display: table-cell; margin-left: 10px} 

, adapted answer of clément question how align input forms in html. using first paragraph header contains labels. following paragraphs contain textareas.

<div>   <h4> h1 </h4>   <p>     <label>id</label>     <label>name</label>     <label>input1</label>     <label>input2</label>     <label>input3</label>     <label>input4</label>   </p>   <p>     <label>123213</label>     <label>test1</label>     <textarea title="1" style="border:1px solid black;"></textarea>     <textarea title="2" style="border:1px solid black;"></textarea>     <textarea title="3" style="border:1px solid black;"></textarea>     <textarea title="4" style="border:1px solid black;"></textarea>   </p>   <p>     <label>456</label>     <label>test2</label>     <textarea title="5" style="border:1px solid black;"></textarea>     <textarea title="6" style="border:1px solid black;"></textarea>     <textarea title="7" style="border:1px solid black;"></textarea>     <textarea title="8" style="border:1px solid black;"></textarea>   </p> </div> 

the first , second columns , labels displayed correctly. textareas. third sixth label of first row aren't displayed intended. table-cell of third label seems span on (instead of one) table-cells of textareas. fourth sixth label seems displayed in additional table-cells outside of intended table width.

here's jsfiddle: https://jsfiddle.net/3rrabvu6/1/

i want each textarea displayed beneath 1 label of first paragraph. how can achieve this?

try this

div     { display: table;      }  p       { display: table-row;  }  label   { display: table-cell; text-align: center;}  textarea{  margin-left: 10px}
<div>    <h4> h1 </h4>    <p>      <label>id</label>      <label>name</label>      <label>input1</label>      <label>input2</label>      <label>input3</label>      <label>input4</label>    </p>    <p>      <label>123213</label>      <label>test1</label>      <label><textarea title="1" style="border:1px solid black;"></textarea></label>      <label><textarea title="2" style="border:1px solid black;"></textarea></label>      <label><textarea title="3" style="border:1px solid black;"></textarea></label>      <label><textarea title="4" style="border:1px solid black;"></textarea></label>    </p>    <p>      <label>456</label>      <label>test2</label>      <label><textarea title="5" style="border:1px solid black;"></textarea></label>      <label><textarea title="6" style="border:1px solid black;"></textarea></label>      <label><textarea title="7" style="border:1px solid black;"></textarea></label>      <label><textarea title="8" style="border:1px solid black;"></textarea></label>    </p>  </div>


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -