How to right-align form input boxes?

前端 未结 8 650
野的像风
野的像风 2021-01-01 08:53

I have a seemingly easy problem to solve, but am struggling. How do I get these two inputs to align to the right of the form, without using the BR element ?

         


        
相关标签:
8条回答
  • 2021-01-01 09:15

    I answered this question in a blog post: https://wscherphof.wordpress.com/2015/06/17/right-align-form-elements-with-css/ It refers to this fiddle: https://jsfiddle.net/wscherphof/9sfcw4ht/9/

    Spoiler: float: right; is the right direction, but it takes just a little more attention to get neat results.

    0 讨论(0)
  • 2021-01-01 09:16

    Use some tag, to aligning the input element. So

    <form>
       <div>
         <input>
         <br />
         <input>
        </div>
    </form>
    
        .mydiv
         {
            width: 500px;
            height: 250px;
            display: table;
            text-align: right;
         }
    
    0 讨论(0)
提交回复
热议问题