Textarea 对于容器来说太小了。连手动放大都做不到
Textarea is too small for the container. Can't even manually enlarge it
我在某些 div 块中遇到 textarea
问题。无论我做什么,它都不会接受块的完整 width
。我试着给它一个固定的 100% width
,我试着给它更多的列,我试着在浏览器中手动增加大小,它只是不会填满整个容器,我不明白为什么。它的行为,好像在它的右边有一个看不见的col,但实际上没有。
**注:**textarea
之前的文字部分(testwethsfjg.....)只是为了看文字是否会与textarea
绑定在相同的边界上.
也许有人知道问题出在哪里。帮助将不胜感激。
代码
.comment-box {
padding-top: 20px;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 20px;
margin-left: 200px;
margin-right: 200px;
background-color: #e9dac6;
border-radius: 25px;
border: 3px solid green;
}
.comment-box-empty {
margin-bottom: 20px;
background-color: white;
border-radius: 25px;
border: 1px solid black;
}
.comment-box-full {
margin-top: 20px;
margin-bottom: 0px;
margin-left: 30px;
margin-right: 30px;
background-color: white;
border-radius: 25px;
border: 1px solid black;
}
.comment-box-top {
margin: auto;
padding-left: 15px;
padding-right: 15px;
padding-top: 10px;
padding-bottom: 10px;
background-color: #faebd7;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
border: none;
width: 100%;
height: 100%;
}
.comment-box-top-text {
font-size: 19px;
font-weight: bold;
line-height: 1;
width: auto;
height: auto;
display: inline;
}
.comment-box-content {
padding-left: 15px;
padding-right: 15px;
padding-top: 10px;
padding-bottom: 10px;
border: none;
width: 100%;
}
.comment-box-content-text {
text-align: justify;
font-size: 17px;
font-weight: 400;
line-height: 1.25;
}
<div class="comment-box">
<div class="comment-box-empty">
<form id="usr_comment">
<div class="comment-box-top">
<div class="comment-box-top-text">
<label for="name">Name:</label>
<input type="text" size="10" name="name" />
<label for="email">Email:</label>
<input type="email" size="15" name="email" />
<br />
<input type="checkbox" name="show_mail" value="showmail" checked />
<label for="show_mail">E-Mail für alle Sichtbar anzeigen?</label>
<br />
</div>
</div>
<div class="comment-box-content">
testwethsfjggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
<br />
<textarea></textarea>
<br />
<br />
<button type="submit" class="btn btn-primary btn-sm">Post</button>
</div>
</form>
</div>
@{ foreach (var comment in ViewBag.rb1.CommentList) { if (ViewBag.rb1count > 0) {
<div class="comment-box-full">
<div class="comment-box-top">
<div class="comment-box-top-text">
@comment.Name @comment.Email
</div>
</div>
<div class="comment-box-content">
<div class="comment-box-content-text">
@comment.Content
</div>
</div>
</div>
} } }
</div>
你需要将 width:100%
给 textarea
,如果还没有,请重置 margin/padding
,并停止调整 width
的大小我可以使用 resize:none
或 resize:vertical
取决于你的情况
这是一个示例:
div {
width: 500px;
border: red solid;
box-sizing: border-box;
padding: 5px;
}
textarea {
width: 100%;
margin: 0;
padding: 0;
resize:vertical
}
<div>
<textarea></textarea>
</div>
其实你可以给你的textarea设置宽度,但是一旦用户手动更改它,css就不再起作用了,所以你可以添加一个resize:none来保证宽度文本区域
textarea {
resize: none;
width: 90%;
}
我在某些 div 块中遇到 textarea
问题。无论我做什么,它都不会接受块的完整 width
。我试着给它一个固定的 100% width
,我试着给它更多的列,我试着在浏览器中手动增加大小,它只是不会填满整个容器,我不明白为什么。它的行为,好像在它的右边有一个看不见的col,但实际上没有。
**注:**textarea
之前的文字部分(testwethsfjg.....)只是为了看文字是否会与textarea
绑定在相同的边界上.
也许有人知道问题出在哪里。帮助将不胜感激。
代码
.comment-box {
padding-top: 20px;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 20px;
margin-left: 200px;
margin-right: 200px;
background-color: #e9dac6;
border-radius: 25px;
border: 3px solid green;
}
.comment-box-empty {
margin-bottom: 20px;
background-color: white;
border-radius: 25px;
border: 1px solid black;
}
.comment-box-full {
margin-top: 20px;
margin-bottom: 0px;
margin-left: 30px;
margin-right: 30px;
background-color: white;
border-radius: 25px;
border: 1px solid black;
}
.comment-box-top {
margin: auto;
padding-left: 15px;
padding-right: 15px;
padding-top: 10px;
padding-bottom: 10px;
background-color: #faebd7;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
border: none;
width: 100%;
height: 100%;
}
.comment-box-top-text {
font-size: 19px;
font-weight: bold;
line-height: 1;
width: auto;
height: auto;
display: inline;
}
.comment-box-content {
padding-left: 15px;
padding-right: 15px;
padding-top: 10px;
padding-bottom: 10px;
border: none;
width: 100%;
}
.comment-box-content-text {
text-align: justify;
font-size: 17px;
font-weight: 400;
line-height: 1.25;
}
<div class="comment-box">
<div class="comment-box-empty">
<form id="usr_comment">
<div class="comment-box-top">
<div class="comment-box-top-text">
<label for="name">Name:</label>
<input type="text" size="10" name="name" />
<label for="email">Email:</label>
<input type="email" size="15" name="email" />
<br />
<input type="checkbox" name="show_mail" value="showmail" checked />
<label for="show_mail">E-Mail für alle Sichtbar anzeigen?</label>
<br />
</div>
</div>
<div class="comment-box-content">
testwethsfjggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
<br />
<textarea></textarea>
<br />
<br />
<button type="submit" class="btn btn-primary btn-sm">Post</button>
</div>
</form>
</div>
@{ foreach (var comment in ViewBag.rb1.CommentList) { if (ViewBag.rb1count > 0) {
<div class="comment-box-full">
<div class="comment-box-top">
<div class="comment-box-top-text">
@comment.Name @comment.Email
</div>
</div>
<div class="comment-box-content">
<div class="comment-box-content-text">
@comment.Content
</div>
</div>
</div>
} } }
</div>
你需要将 width:100%
给 textarea
,如果还没有,请重置 margin/padding
,并停止调整 width
的大小我可以使用 resize:none
或 resize:vertical
取决于你的情况
这是一个示例:
div {
width: 500px;
border: red solid;
box-sizing: border-box;
padding: 5px;
}
textarea {
width: 100%;
margin: 0;
padding: 0;
resize:vertical
}
<div>
<textarea></textarea>
</div>
其实你可以给你的textarea设置宽度,但是一旦用户手动更改它,css就不再起作用了,所以你可以添加一个resize:none来保证宽度文本区域
textarea {
resize: none;
width: 90%;
}