全宽透明文本区域输入

新手上路,请多包涵

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

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

如果有人能指出我保存和清除笔记,那也很好。

原文由 Dvorak 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 222
2 个回答

根据您发布的图像,将文本区域包装在容器中。

 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: #fff;
  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>

原文由 m4n0 发布,翻译遵循 CC BY-SA 4.0 许可协议

 * {
  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;
}
 <textarea placeholder="">Sed augue ipsum, egestas nec, vestibulum et, malesuada adipiscing, dui. Aenean commodo ligula eget dolor. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. Suspendisse faucibus, nunc et pellentesque egestas, lacus ante convallis tellus,
  vitae iaculis lacus elit id tortor. Curabitur blandit mollis lacus. Quisque ut nisi. Cras varius. Praesent ut ligula non mi varius sagittis.</textarea>

原文由 Vitorino fernandes 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题