简体   繁体   English

如何使占位符不是 go 消失?

[英]How do I make the placeholder not go away?

I'm going to use a textarea to leave comments, but I wanted it to never disappear so I thought about saving it in the database and so when it comes to bringing, using the placeholder, but today if I type something over it it replaces the things that are in the placeholder and I would like you to enter and start typing without affecting the placeholder我将使用 textarea 来发表评论,但我希望它永远不会消失,所以我考虑将它保存在数据库中,所以当涉及到使用占位符时,但是今天如果我在它上面输入一些东西,它会替换占位符中的内容,我希望您在不影响占位符的情况下输入并开始输入

<form action="" method="post">
  <label for="obs">Obs:</label>
  <textarea
    class="form-control"
    name="obs"
    rows="5"
    placeholder="aaaaaaaaaaa"
  ></textarea>
  <button type="submit" class="mt-2 btn btn-primary" name="button">Save</button>
</form>

As far as I know it isn't possible to always show the placeholder.据我所知,不可能总是显示占位符。 However you could use this little trick to fake it.但是,您可以使用这个小技巧来伪造它。 I hope this is what you mean.我希望这就是你的意思。

    <style>
      .placeholder {
         position: absolute;
         margin-left: 5px;
         opacity: .5;
       }
    </style>
    
    <form action="" method="post">
       <label for="obs">Obs:</label>
       <div>
        <span class="placeholder">aaaaaaa</span>
        <textarea class="form-control" name="obs" rows="5"></textarea>
       </div>
      <button type="submit" class="mt-2 btn btn-primary" name="button">Save</button>
    </form>

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

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