目前我分别为 HTML 和 CSS 设置了这个:.....我将如何使用 <div>
构造看起来相同的 CSS 和 html .我创建的那个有水平滚动,看起来很疯狂。
<textarea class="textarea_readonly" readonly="readonly" name="mcRemarkOld" rows="7" cols="100" scrolling="auto"></textarea>
.textarea_readonly
{
background-color: #DDDDD0;
margin: 0px;
width: 100%;
}
最佳答案
与其尝试模仿 div,不如使用 JavaScript 替换文本区域。用法(负载运行):
var textarea = document.getElementsByName("mcRemarkOld")[0];
turnTextAreaIntoDiv(textarea);
function turnTextAreaIntoDiv(elem){
var div = document.createElement("div");
// Copy significant attributes, customize.
div.className = elem.className;
div.style.cssText = elem.style.cssText;
div.id = elem.id;
div.name = elem.name;
div.innerHTML = elem.innerHTML; //`<a>` turns in <a>
elem.parentNode.replaceChild(div, elem);
}
fiddle :http://jsfiddle.net/7bTNH/
关于html - 试图让 <textarea> 模仿 <div>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8084848/