HTML注释框自动不增加高度
HTML Comment Box automatically not increasing height
我从互联网上得到了创建评论框的HTML代码。它工作得很好,但是随着评论数量的增加,评论会出现在它下面的文本上。我希望评论显示在一个特定的滚动条框。我使用了div,但是注释仍然会自动弹出。
我已经尽力了,但就是找不到解决办法。下面是我使用的css -
<style>
#details {
display : block;
background-color : #9494FF;
height : 20px;
width : 130px;
padding : 4px;
border-radius : 10px;
border : 1px solid black;
cursor : pointer;
}
summary::-webkit-details-marker {
display: none
}
textarea {
resize : none;
}
#para {
display : block;
overflow : none;
height : 200px;
width : 100%;
resize : none;
}
</style>
这里是代码-
<ul>
<form>
<textarea id="words" rows="3" cols="60">Enter Comment</textarea>
<input type="button" onclick="getwords()" value="Comment" /> <br>
<details id="details"><summary><center>View Comments</center></summary><div id="para"></div></details>
</form>
<script type="text/javascript">
function getwords() {
text = words.value;
document.getElementById("para").innerHTML += '<div>'+text
document.getElementById("words").value = "Enter Comment"
}
</script>
</ul>
为包装器赋予div属性
overflow: scroll;
在你的CSS-code
删除resize none属性,使其不会增加大小。
textarea {
resize : none; /* Remove this */
}
如果你想让它出现在滚动条中,你必须将overflow : none
更改为overflow : auto
添加溢出属性
#para {
display : block;
overflow : auto;
height : 200px;
width : 100%;
resize : none;
}
忘记给JS字符串添加结束标记
<script type="text/javascript">
function getwords() {
text = words.value;
document.getElementById("para").innerHTML += '<div>'+ text + '</div>'
document.getElementById("words").value = "Enter Comment"
}
</script>
相关文章:
- 根据元素高度和宽度的百分比变化增加或减少字体大小
- 如何使“onmouseout”事件“理解”,即“跨度”高度增加
- 动态增加 iframe 高度
- 表的高度是否随着行中内容的增加而变化
- CSS转换未在增加高度时更新背景色
- 导出时增加图表高度
- 如何增加highchart.js图表上x轴标签区域的高度
- 如何增加光滑块高度,而不考虑其内容
- Div 高度不会在附加任何元素时增加
- 如何在 ag-grid 中增加列标题的高度
- 如何在 AngularJS 中动态增加/减少段落元素的高度
- 钛应用器动态文本区域高度增加
- 文本区域的高度在值增加时增加,但在值减小时不会降低
- 如何防止滚动时此导航栏的高度增加
- 选中复选标记时增加 Div 高度
- 在滚动野生动物园错误上增加元素的高度
- 根据另一个Div内容增加Div高度,它's的高度
- 如何在向下滚动时增加高度,而在向上滚动时不减小
- jQuery .height()增加高度,但不会降低高度
- HTML注释框自动不增加高度