如何让textarea placeholder 文字垂直居中?

如题,有没有一种办法让textarea 中的placeholder文字垂直居中呢

阅读 15.2k
2 个回答
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    #textArea {
      color: white;
      height: 50px;
    }
    #textArea::-webkit-input-placeholder{
      height: 50px;line-height: 50px
    }    /* 使用webkit内核的浏览器 */
    #textArea:-moz-placeholder{
      height: 50px;line-height: 50px
    }                  /* Firefox版本4-18 */
    #textArea::-moz-placeholder{
      height: 50px;line-height: 50px
    }                  /* Firefox版本19+ */
    #textArea:-ms-input-placeholder{
      height: 50px;line-height: 50px
    }
  </style>
</head>
<body>
  <textarea id="textArea" name="" placeholder="请输入"></textarea>
</body>
</html>

设置

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