Search code examples
javascripthtmlalignment

How to align button to text area


As you can see in this fiddle https://jsfiddle.net/3spqLzx1/1/ I would like to align vertically (on the same line) my text area with my button, but the button keeps on being pushed downwards. Could you please tell me a way to make them align? Thank you

Text area + Button HTML

<p id="headings"><textarea name="msg" style="height:40px;text-align:center"  id="message" placeholder="Insert your message here"></textarea></p>
<p id="button"><input type="button" value="Send" onclick="submitChat()"    id="innerbutton"></p>

CSS

#headings {
text-align:center;
display:inline-block;
width:70% !important;
margin-top:20px;
}
#headings {
text-align:center;
display:inline-block;
width:70% !important;
margin-top:20px;
}
#message {
width:100%;
}
#button {
text-align:center;
display:inline-block;
width:8%;
margin-top:-30px !important;
border:solid black;
height:50px;
}
#innerbutton {
width:100%;
height:50px;
margin-top:25px;
background-color:rgb(22, 33, 211);
text-decoration:none;
margin-bottom:30px;
}

Solution

  • Here are the changes:

    #innerbutton {
    ...
    -margin-top: 25px;
    ...
    }
    
    
    #button {
    ...
    - margin-top:-30px !important;
    + vertical-align: top;
    ...
    }
    

    jsFiddle