gpt4 book ai didi

html - CSS 和 HTML。如何在一行中显示两个div

转载 作者:行者123 更新时间:2023-11-28 16:55:02 25 4
gpt4 key购买 nike

这是一个非常简单的问题:我有两个元素应该以特定比例显示在一行中。然后应在下一行重复相同的模式。但是,后一行的内容打印在前一行未使用的空间中。显然是css文件的问题。

我想这个例子会很清楚:

.row1 {
float: left;
width: 70%;
margin-bottom: 50px;
}
<head>
<link rel="stylesheet" type="text/css" href="syle.css">
</head>
<div>
<div class="paragraph1">
<h1> Paragraph 1 </h1>

<h3> subtitle1 </h3>
<div class="row1">
<p class="row1_col1"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="row1_col2">
<p> Just some other text</p>
</div>
</div>

<div class="paragraph1">
<h1> Paragraph 1 </h1>

<h3> subtitle1 </h3>
<p class="row1_col1"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="row1_col2">
<p> Just some other text</p>
</div>
</div>
</div>

有什么想法吗?

最佳答案

这是一个不太优雅的解决方案(链接中的完整代码)

https://jsfiddle.net/qk7o8w4t/1/

.paragraph {
display: inline-block;
width: 50%;
}

.right {
float: right;
}

.left {
float:left;
}

关于html - CSS 和 HTML。如何在一行中显示两个div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57381766/

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