简体   繁体   中英

How to align the form to the center properly?

I can set the form width manually but every changes in the <input> width will lead to the troubles, specifically I'll be should adjust form width again. I need scalable alignment ie changes in input width shouldn't impact on the form's alignment.

 form { width: 400px; margin: 0 auto; } [type=text] { /* width: 100px; */ } canvas { display: block; margin: 10px auto; border: 1px dashed gray; } 
 <form> <input type="text" id="left"/> <input type="submit" value=">>"/> <input type="text" id="right"/> </form> <canvas width="40" height="200"></canvas> 

You can set the form to display:table , and don't need to set the width at all.

 form { margin: 0 auto; display: table; } 
 <form> <input type="text" id="left"/> <input type="submit" value="&gt;&gt;"/> <input type="text" id="right"/> </form> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM