简体   繁体   中英

Getting text to vertically line up within text input field

I'm using Foundation 6 framework to construct my pages. I have a separate style sheet called effects.css that I use to customize text and tables and inputs and such.

I actually have to style it, because without the custom styles the input fields are huge and grotesque. Must be some scaled styles in the foundation.css that are responsible.

I made a short, thin text input field, but the text inside doesn't seem to want to vertically line up correctly. The cursor blinks up and sort of half way out of the white text area.

Here's the html:

<form name="quick-connect" id="quick-connect" method="post" action="/ajax/quick-connect-action/" onsubmit="return false;">
    <span class="med-text white-text">Your name:</span><input type="text" name="name" id="name" class="small-input" />
    <span class="med-text white-text">Your phone #:</span><input type="text" name="number" id="number" class="small-input" />
    <input type="submit" name="submit" id="quick-connect-submit" value="Submit" />
    <input type="hidden" name="page" value="LCHG" />
</form>

Here's my attempt at css'ing the input fields:

input.small-input{
    width:10em;
    height:1em;
    line-height:1em;
    font-size:.9em;
    color:#000;
}

Here's what it looks like:

光标向上输入文字过多

The blinking text cursor isn't vertically align within the text field.

It was a padding problem. I set the padding to 0 within the input style, and the text properly vertically aligns now.

input.small-input{
    width:10em;
    height:2em;
    line-height:2em;
    font-size:.8em;
    color:#000;
    padding:0;
}

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