HTML/CSS:文本类型输入上方和下方的额外间距

Joh*_*hnB 9 html css html5

实例:http://jsfiddle.net/yDQXG/

我在Chrome中看到的内容:http://i.imgur.com/shLfA.png

我似乎无法弄清楚输入元素(蓝色字段)周围的间距来自何处.有任何想法吗?

<form method="get">
<fieldset class="halfblock">
    <input class="blockheader" type="text" value="Field A">
    <textarea class="blocktext" rows="5">Line 1&#13;&#10;Line 2</textarea>
</fieldset>
</form>
Run Code Online (Sandbox Code Playgroud)

Bri*_*ian 6

设置行高:0px;在 .halfblock 上

.quote_body .halfblock {
    width: 262px;
    border: 1px dotted 
    #333;
    float: left;
    margin-bottom: 15px;
    line-height: 0px;
}
Run Code Online (Sandbox Code Playgroud)


coo*_*ita 6

It's because they are inline elements. Same thing happens often with images.

All you need to do is add display:block to your inputs:

input.blockheader {
    margin: 0;
    padding: 0;
    text-align: center;
    background: #ABD9E2;
    font: 11px/11px 'Vollkorn', serif;
    border: none;
    width: 100%;
    position: relative;
    /* top: -7px; */

    display: block;
}
Run Code Online (Sandbox Code Playgroud)