简体   繁体   中英

How to connect a button to an input

How would I make the button connect to the input, there is an awkward gap I don't know how to fix.

这是输入和按钮

  #ask {

        padding: 10px  10px 10px 6px;
        font-size:45px;
        background-color:#FAFAFA;
        min-width: 400px;
        padding: 0 auto;
        border-radius: 5px;

  }

#button {
      text-align:center;

      }

 </style>


   <input id="ask" type="text" placeholder = "Ex: how tall is the gateway arch" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Ex: how tall is the gateway arch'"/>
   <input type="image" src="qmb.png" name="saveForm" class="btTxt submit" id="button" height="50.5px" padding = "0px"/>

Use CSS float:left to get input & image side by side.

input, img {
    float:left;
}

Please check this fiddle: http://jsfiddle.net/hnj604pr/

Wrap your input tags in a div like this:

<div>
    <input....>
    <input....>
</div>

This way the browser will align them for you.

You also might want to consider changing your second input tag to use the button or submit tag.

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