html - 通过 slde 将同一侧并排显示为两行
问题描述
我使用了一个代码,如下所述。我需要并排显示 div 中的内容,而不是向下显示。我无法更改 div,因为 div 实际上是按时间重复的。在我的代码中,我写的第一个 div 是重复的,所以我不能更改 div,第一个 div 中的任何更改也反映在其他 div 中。请为此提供解决方案。先感谢您。
<style>
.your_container {
display: flex;
flex-wrap: wrap;
align-items: center;
}
.wfte_invoice-main {
color: #73879c;
font-family: "Helvetica Neue", Roboto, Arial, "Droid Sans", sans-serif;
font-size: 12px;
font-weight: 400;
line-height: 18px;
box-sizing: border-box;
width: 50%;
margin: 0px;
}
</style>
<div class="your_container">
<p class="wfte_invoice-main">
2 any street basingstoke, United Kingdom, SP49 4ED
</p>
</div>
<div class="your_container">
<p class="wfte_invoice-main">
2 any street basingstoke, United Kingdom, SP49 4ED
</p>
</div>
解决方案
放置一个包装器your_container
并将包装器样式设置为display: flex
.
CSS:
.main-wrapper {
display: flex;
}
.your_container {
display: flex;
flex-wrap: wrap;
align-items: center;
width: 50%; /* width of the container */
padding: 0 15px; /* to add spaces between container */
}
.wfte_invoice-main {
color: #73879c;
font-family: "Helvetica Neue", Roboto, Arial, "Droid Sans", sans-serif;
font-size: 12px;
font-weight: 400;
line-height: 18px;
box-sizing: border-box;
width: 50%;
margin: 0px;
}
HTML:
<div class="main-wrapper">
<div class="your_container">
<p class="wfte_invoice-main">
2 any street basingstoke, United Kingdom, SP49 4ED
</p>
</div>
<div class="your_container">
<p class="wfte_invoice-main">
2 any street basingstoke, United Kingdom, SP49 4ED
</p>
</div>
</div>
推荐阅读
- firebase - Firebase 部署错误。服务器错误。客户端网络套接字在建立安全 TLS 连接之前断开
- multithreading - 在为 Runnable 提供 lambda 时,为什么我不必重写 run 方法?
- reactjs - 基于反应原生中TextInput的变化渲染视图
- c++ - 在构建编译器时出现错误“int 之前的预期初始化程序”一直在尝试学习 c++,我只是一直卡住
- nuxt.js - 如何在 SSR(通用)模式下将 Nuxt JSON 有效负载与 HTML 分离?
- java - 客户端发出命令后停止服务器套接字
- r - 创建一个列表子集数据框并根据 r 中的先前加入其他列表
- java - 测试涉及 ScheduledExecutorService#scheduleAtFixedRate 的代码的单元测试失败
- angular - Angular - 显示来自子组件内的导入组件的激活路由数据
- uwp - 在 InkCanvas 中调整已绘制的 Inkstrokes 的大小