【发布时间】:2022-06-11 08:06:29
【问题描述】:
我遇到了关于容器或/和文本区域高度的 CSS 问题。生成的 div 和 textareas 应该动态设置高度。不幸的是,这并没有像我预期的那样成功。如何更改 CSS,以便附加的 textarea 足够大以适应内容。我不想要溢出滚动条。
https://jsfiddle.net/j4s81hpa/
data = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ips um has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."
$("#flow-desc").html("")
for (var i = 0; i < 4; i++) {
$("#flow-desc").append('<div class="notes-container" id='+ i +'><textarea class="notes-textfield col-10" placeholder="#Notiz">'+ data +'</textarea></div>')
}
.flow-div {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 33.33%;
background: whitesmoke;
opacity: 1;
}
.wrapper {
position: relative;
margin: 20px;
height: fit-content;
background: white;
border-radius: 10px;
box-shadow: -10px -10px 10px rgba(255, 255, 255, 0.5),
15px 15px 15px rgba(70, 70, 70, 0.12);
padding: 10px;
overflow-y: auto;
}
.notes-container {
position: relative;
margin: 20px;
height: fit-content;
}
.notes-textfield {
position: relative;
border-radius: 10px;
padding: 10px 10px 0 10px;
border: none;
resize: none;
overflow: hidden;
height: fit-content;
border-bottom: 2px solid rgb(0, 50, 115, 0.25);
width: calc(100% - 20px);
}
#flow-desc {
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div class="flow-div">
<div class="wrapper">
<div id="flow-desc">
<!-- .. filled by script .. -->
</div>
</div>
</div>
【问题讨论】:
标签: css