简体   繁体   中英

align input text vertically

I have a input text element whose height is adjusted and the text is aligned to right.

How can I align it vertically (on baseline)?

I tried adding some padding to the input elememt at the top and it works. However, I would like to know if there is any property that can be set to align it vertically.

I also tried to set display: inline-block and vertical-align: text-bottom but didn't work.

This is my input element:

<input id="display" type="text" />

Here is the css code:

form #display {
    height: 10 %;
    width: 100 %;
    border: none;
    background-color: rgb(12, 37, 30);
    color: white;
    text-align: right;
    padding-right: 20px;
    font-family: 'Gotham Rounded Light', sans-serif;
    font-size: 12px;
}

You can try a couple of solution,

vertical-align: middle

another one

input[type=text] {
 height: 15px; 
 line-height: 15px;
}

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