gpt4 book ai didi

html - 两个 div 彼此相邻,堆叠响应变化

转载 作者:行者123 更新时间:2023-11-28 14:00:47 24 4
gpt4 key购买 nike

我试图通过仅更改 CSS 而在不更改 HTML 的情况下实现某些目标。

在两列中,textarea-div 的宽度应该是双倍的,在一列中,textarea-div 的宽度不应更改,

https://www.bilder-upload.eu/upload/c314f9-1567495199.png对不起,我没有声誉,所以无法发布图片

<style>
.paragraph {line-height: 20px;display: inline-block;padding: 4px;}
.text,.textarea{display: block;width: 200px;}
</style>

<div class="form form_shortcode">
<form target="_self" method="post">
<p class="paragraph"><input type="text" class="text"></p>
<p class="paragraph"><input type="email" class="text"></p>
<p class="paragraph"><input type="text" class="text"></p>
<p class="paragraph"><input type="text" class="text"></p>
<p class="paragraph"><textarea class="textarea" rows="3"></textarea></p>
</form>
</div>

最佳答案

您可以使用以下 css 来实现此目的。我添加了注释以进行解释,但如果有任何不清楚的地方,请随时询问。

.form_shortcode > form {
font-size: 0; /* needed to remove space between inline-blocks */
}
.paragraph {
line-height: 20px;
display: inline-block;
padding: 4px;
margin: 0;
vertical-align: top;
width: 50%; /* set to half of parent's width */
box-sizing: border-box; /* don't add padding to total width */
font-size: initial; /* reset font-size 0 */
}
.paragraph:last-child {
width: 100%; /* make last one span the full width */
}
.text,
.textarea{
display: block;
width: 100%;
}

@media (max-width: 500px) {
.paragraph {
width: 100%; /* set all to full width */
}
}

JSFiddle:https://jsfiddle.net/Lw3ybteq/

关于html - 两个 div 彼此相邻,堆叠响应变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57766941/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com