简体   繁体   English

css适用于输入文本而非文本区域

[英]css works on input text not text area

This is a jsfiddle 这是一个jsfiddle

http://jsfiddle.net/2GpmW/ http://jsfiddle.net/2GpmW/

when I set the css, I did this: 当我设置CSS时,我这样做了:

.inputForm input[type="text"], .inputForm input[type="email"], .inputForm textarea, .inputForm select {
    border: none;
    color: #525252;
    height: 30px;
    line-height: 15px;
    margin-bottom: 10px;
    margin-right: 6px;
    margin-top: 2px;
    outline: 0 none;
    padding: 2px 0px 2px 5px;
    width: 400px;
    border-radius: 2px;
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
    background: #DFDFDF;
    font-family: inherit;
    font-size: inherit;
}

so as you see the css show be applied to both input text and text area but for some reasons, the label beside the text area becomes down and place holder inside the text area is not centered vertically as it is in the input text 因此,当您看到css show应用于输入文本和文本区域时,但由于某些原因,文本区域旁边的标签变为向下,文本区域内的占位符不会垂直居中,因为它在输入文本中

please : 请 :

1- why is that happening? 1-为什么会发生这种情况?

2- how to solve it 2-如何解决它

Many thanks 非常感谢

You have to use this: 你必须使用这个:

textarea{
    vertical-align: top;
}

fiddle 小提琴

The vertical-align CSS property specifies the vertical alignment of an inline or table-cell element. vertical-align CSS属性指定内联或表格单元格的垂直对齐方式。

You have to add vertical-align:middle to both textarea and label. 您必须在textarea和label中添加vertical-align:middle。

label, textarea{
 vertical-align: middle;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM