-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[html] 第35天 用一个div模拟textarea的实现 #128
Comments
<div class="edit" contenteditable="true">这里是可以编辑的内容,配合容器的 overflow ,多行截断,自定义滚动条,简直好用的不要不要的</div> |
上面的代码实现了div变为可编辑状态,但是textarea标签可以在右下角自由拉伸 <div class="edit" contenteditable="true" style="resize: both"></div> 这样就可以啦 |
哈哈 ,在补充一点,加上
我在codepen上做了一个演示地址,有兴趣的可以查看:https://codepen.io/ansonznl/pen/LozrgK |
加上一个最小高度和最小宽度,这样用户体验会更好 |
楼上都很赞 |
如果样子也要像的话,可以加上 |
<div contenteditable="true"></div> |
楼上都是大佬,萌新佩服 |
主要是利用了 HTML5 提供的 contenteditable 属性,让普通的 如果需要对输入的值进行处理,就还需要用上 JS。 codepen 地址:https://codepen.io/Konata9/pen/yLBovJE |
楼上们很强 |
添加一点,如果设置 如果不需要该需求的话可以设置 contenteditable 属性可以设置这几个值: |
萌新佩服大佬,学到了 |
|
|
楼上都很棒! |
div 设置contenteditable属性就可以做到实现textarea |
第35天 用一个div模拟textarea的实现
The text was updated successfully, but these errors were encountered: