Dennis Leung

前端小天才智多星班进修中

  • 主页
  • 干货储物柜
所有文章 关于我

Dennis Leung

前端小天才智多星班进修中

  • 主页
  • 干货储物柜

为contenteditable增加placeholder

2020-05-22

加了contenteditable的div默认是没有placeholder的,下面尝试用css实现一个placeholder的效果:

1
<div class="richTextBox empty" contenteditable placeholder="请输入"></div>
1
2
3
4
5
6
7
8
9
10
.richTextBox {
border: 1px solid #eee;
height: 100px;
}
.richTextBox.empty:before {
position: absolute; /*强制使伪元素脱离文档流,否则ff下输入的文字会跟在placeholder后面*/
content: attr(placeholder); /*注意这里不能用引号*/
color: #ddd;
cursor: text;
}

效果图:
效果图

  • html
  • css
19. Remove Nth Node From End of List
用纯css实现一个iOS的switch开关
© 2023 Dennis Leung
Hexo Theme Yilia by Litten

粤公网安备 44030502007083号

粤ICP备2021020087号

  • 所有文章
  • 关于我

tag:

  • leetcode
  • 算法
  • 并查集
  • JavaScript
  • 干货储物柜
  • Yii
  • php
  • Python
  • http
  • html
  • HTML
  • CSS
  • hexo
  • javascript
  • hybrid
  • 网络安全
  • Apple Script
  • 爬虫
  • 微信公众号
  • css
  • 数据结构
  • 编译原理
  • 位运算
  • 干活储物柜
  • 移动开发

    缺失模块。
    1、请确保node版本大于6.2
    2、在博客根目录(注意不是yilia根目录)执行以下命令:
    npm i hexo-generator-json-content --save

    3、在根目录_config.yml里添加配置:

      jsonContent:
        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true
    

不思进取的前端开发攻城狮。
梦想是躺着也能拯救世界。