简体   繁体   English

输入和Textarea样式问题

[英]Input and Textarea styling issues

So this question has been sort of hounding me. 所以这个问题一直困扰着我。 Let's say I have two input fields and a textarea. 假设我有两个输入字段和一个文本区域。 For some reason, the spacing between the three is inconsistent. 由于某些原因,这三个之间的间距不一致。 The gap between the first input to the textarea is different than that from the textarea to the second input field, no matter what I set the margin values to. 无论我将边距值设置为什么,文本区域的第一个输入之间的距离都不同于文本区域和第二个输入字段之间的距离。

Additionally, the whitespace between the border and the start of the first character on both the input field and textarea is inconsistent, as well as the font styles applied to each. 此外,输入字段和文本区域上边框与第一个字符的开头之间的空格以及应用于每个字体的字体样式均不一致。 This occurs despite me using Eric Meyer's CSS reset, which I had hoped would fix the issue. 尽管我使用了Eric Meyer的CSS重置,但仍会发生这种情况,我希望此重置能够解决此问题。

And a final issue (as it seems to never end) is that the textarea by default has a scrollbar to the side in internet explorer that I can rid by using overflow: hidden, although this creates obvious problems... Is there perhaps a cleaner solution? 最后一个问题(似乎永无止境)是,默认情况下,textarea在Internet Explorer的侧面具有滚动条,我可以使用溢出功能来隐藏它:隐藏,尽管这会带来明显的问题...也许更清洁了吗?解?

HTML HTML

 <ul>
  <li><input type="text" name="title" class="input_x" value="Title" /></li>
  <li><textarea name="description" class="textarea_x">Description</textarea></li>
  <li><input type="text" name="title" class="input_x" value="Title" /></li>
 </ul>

CSS CSS

  .input_x, .textarea_x {
   -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
   -moz-box-sizing: border-box;    /* Firefox, other Gecko */
   box-sizing: border-box;         /* Opera/IE 8+ */
   padding: 0;
   width: 100%;
   border: 1 solid #EEFF00;
   resize: none;
  }

  ul {
   list-style: none;
   padding-left: 0;
  }

  input {
   margin: 0;
   padding: 0;
  }

http://jsfiddle.net/rY87q/ http://jsfiddle.net/rY87q/

I believe that textarea { overflow: auto; } 我相信textarea { overflow: auto; } textarea { overflow: auto; } is exactly what you are looking for. textarea { overflow: auto; }正是您想要的。 It hides the scrolling bar until there is enough text to have need for the bar. 它会隐藏滚动条,直到有足够的文本需要该滚动条为止。 This is compatible with all modern browsers so no cross-browser formatting problems. 这与所有现代浏览器兼容,因此没有跨浏览器的格式问题。 Reference 参考

As for the spacing add this to the CSS: 至于间距,请将其添加到CSS:

.textarea_x {
    vertical-align: middle;
}

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

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