dtll2016 2017-11-01 11:30
浏览 125
已采纳

可信的div高度限制

Hey guys I have problems with contenteditable height. With code like this:

 function Preview() {
 var x = document.getElementById("code").value;
 document.getElementById("preview").innerHTML = x;
}
  .preview{
text-align: left;
color: white;
margin-left: 10px;
max-height: 300px;
overflow: auto;
}
<section id="main"> 
   <div id="gra"> 
      <input type="hidden" id="current-code" name="current-code" />
         <textarea id="code" name="code">
             <!DOCTYPE html>
               <html lang="en">
                  <head>
                    <meta charset="UTF-8">
                    <title>A Simple PHP File</title>
                  </head>
                  <body>
                    <h1><?php echo "Hello, world!"; ?></h1>
                  </body>
               </html> 
             </textarea>
       <div class="flex">
          <a href="#" class="myButton" onclick="Preview()">Preview</a>
         <a href="#" class="myButton" onclick="Reset()">Reset</a>  
       </div>
      </div>
      <div id="gra">
        <div contenteditable="true" class="preview" id="preview">  
      </div>
    </div>
 </section>

When I enter code with more I can observe effect like this: test

Anyone can help me with limit contenteditable height?

</div>
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 python文本词汇出现次数统计
      • ¥15 使用按键和串口,记录按键在不消抖的情况下触发的次数
      • ¥100 MFC中如何开发类似微信聊天记录的界面?
      • ¥20 想问问RequestMapping能找到controller,但controller中的方法却不起作用
      • ¥15 计算机组成原理设计八位理论计算机整机系统
      • ¥15 把这个迷宫问题代码修改一下
      • ¥15 工具变量 时间序列相关问题
      • ¥15 正弦波的峰值查找算法
      • ¥15 关于lwip的pbuf数据提取问题
      • ¥50 请求关于BBS数据集的资源分享