有什么方法可以让一个文本区域全屏,而不需要额外的CSS文件?

问题描述 投票:-1回答:1

我想让TextArea全屏,不需要额外的CSS文件,也不需要删除文本?

<html>
<title>TextArea</title>
<body>
<textarea spellcheck="true"></textarea>
<p>TextArea</p>
</body>
</html>
html textarea width
1个回答
0
投票

<html>
   <title>TextArea</title>
   <body>
      <textarea spellcheck="true" style="width: 100%;
         height: 100vh;"></textarea>
      <p>TextArea</p>
   </body>
</html>

如果你不想创建一个单独的CSS样式表,你可以添加内联样式。


0
投票

使用内联样式。

<html>

<head>
  <title>Fullscreen Textarea</title>

  <body style="width:100px; height:100px;">
    <textarea style="width: 100%; height:100%;"></textarea>
  </body>

</html>

或者,使用 <style> 标签。

<html>

<head>
  <title>Fullscreen textarea</title>
</head>

<body>
  <textarea id="textarea"></textarea>
</body>
<style>
  body {
    width: 100px;
    height: 100px;
  }
  
  #textarea {
    width: 100%;
    height: 100%;
  }
</style>

</html>

两者效果相同,但在可能的情况下最好不要使用内联样式。

© www.soinside.com 2019 - 2024. All rights reserved.