全宽透明Textarea输入

时间:2015-07-29 18:21:09

标签: html css html5 css3

我正在尝试使用HTML5和CSS制作笔记应用程序。在尝试从用户那里获取输入时,我希望textarea是全宽(100%)并且是透明的。

所以,基本上,文本区域应该是透明的,页面应该只显示一个白色光标,并且应该没有溢出。

如果有人可以指示我保存并清除笔记,那也会很棒。

5 个答案:

答案 0 :(得分:7)

根据您发布的图像,将textarea包装在容器内。

html,
body {
  height: 100%;
  padding: 0;
  margin: 0;
  overflow-x: hidden;
}
.text-container {
  background: #4492E0;
  padding: 20px;
  height: 100%;
  position: relative;
}
textarea {
  background: transparent;
  color: white;
  resize: none;
  border: 0 none;
  width: 100%;
  font-size: 5em;
  outline: none;
  height: 100%;
  position: absolute;
}
<div class="text-container">
  <textarea>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
  
  Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</textarea>
</div>

答案 1 :(得分:0)

喜欢这个?拯救是另一回事,应该是一个新问题。

textarea {
    background:transparent;
    outline:none;
    border:none;
    width:100%;
    font-size:20px;
    color:#fff;
}

答案 2 :(得分:0)

如果你只是在textarea上猛击{width:100%},你通常会得到一个溢出其容器的textarea。因为textarea的宽度将是100%+填充+边框。你需要反击填充和边框。

绝对最简单的方法是向包装元素添加填充

  

输入的宽度是其容器的100%+ 1px + 1px(边框)+ 4px + 4px(填充)。换句话说,宽度是100%+ 10px;因此,我们在修复类中为右侧添加了额外的10px填充。

    <!doctype html>  
<html lang="en">
<head>
 <style>
  label { padding: 0; marign: 0; display: block; }
  textarea { width: 100%; border: 1px solid #333; padding: 4px; }
  .the-fix { padding-right: 10px; }
 </style>

</head>

<body>
 <label class="the-fix">
  A good-looking textarea with a 100% width
  <textarea></textarea>
 </label>
</body>
</html>
  

透明度只需使用CSS DUDE ----

<textarea style="color: black; background-color: transparent;">Your text</textarea> 

答案 3 :(得分:0)

选择您的&#34; textarea &#34;无论如何,你想要并应用这些风格。

textarea{
    width: 100%;
    color: #FFF;
    background: transparent;
    border: none;
    outline: none;
}

答案 4 :(得分:0)

StopIteration
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  height: 100%; /* optional */
}
body {
  background: cornflowerblue;
}
textarea {
  width: 100%;
  height: 100%; /* optional change it to your height */
  padding: 15px;
  background: transparent;
  color: #fff;
  vertical-align: middle; /* removes whitespace as textarea is inline element */
  border: 0;
}