文本不从输入文本字段的左上方开始 [英] Text doesn't start from the left top of input text field

查看:531
本文介绍了文本不从输入文本字段的左上方开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个固定高度的输入字段。文本是垂直居中的,但我想在输入的左上角。

I have an input field with a fixed height. The text is vertically centered, but I want it at the top left of the input.

CSS

.wideInput{
    text-align: left;
    padding:  0.4em;
    width: 400px;
    height: 200px;
}

HTML

<input class="longInput" value="<?php echo $row['foodPrice']; ?>" />

这里有一个jsFiddle演示了问题> http://jsfiddle.net/9cR5j/

Here's a jsFiddle that demonstrates the problem > http://jsfiddle.net/9cR5j/

推荐答案

如果删除 padding:0.4em; 并设置

padding-left:0;
padding-top:0;
padding-bottom:0.4em;
padding-right: 0.4em;

更改后更改类名

<input class="wideInput" value="<?php echo $row['foodPrice']; ?>" />

而不是 longInput c $ c> wideInput

instead of longInput it will be wideInput

更新

使用TextArea的JsFiddle演示

这将使用textarea只因为输入只是允许在一行输入值,即没有输入keyallowed或它打开换行长文本,它只是添加数据在一行

this will work with textarea only because input is just allow to enter value in one line i.e no enter keyallowed or it doent wrap long text , it just add data in one line

这篇关于文本不从输入文本字段的左上方开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆