gpt4 book ai didi

css - 以特定效果对齐列(右/左)

转载 作者:太空宇宙 更新时间:2023-11-04 05:49:57 25 4
gpt4 key购买 nike

我正在学习 CSS,并且正在集成一个设计模板 (PSD)。

我遇到了一个小问题,我必须对齐4 列2 列在左边2 列在右边 ...

问题是右边的 2 列应该稍微在左边的 2 列下方。(看图片)

The Picture

我在寻找解决方案......但我没有准确地找到我正在寻找的东西。

我尝试了很多东西(bootstrap、margin-top ...等)但我认为有一个更合乎逻辑的解决方案...你能帮帮我吗?

提前谢谢你。

我的代码:

.our-approach {
height: fit-content;
height: -webkit-fill-available;
background-color: beige;
}
.our-approach-content {
max-width: 730px;
margin: auto;
}
.our-approach-content p {
border-radius: 10px;
}
.our-approach-content .col {
background-color: cadetblue;
padding: 20px;
border-radius: 10px;
margin: 10px;
}
<section class="our-approach">
<div class="container jumbotron">
<div class="tl-content our-approach-content">
<h1 class="text-center">Our Approach</h1>
<h2 class="text-center">How we do it</h2>
<div class="oac-legend">
<div class="oac-l">
<div class="row">
<div class="col"><p>
Lorem Ipsum is simply dummy text of the printing and
typesetting industry. Lorem Ipsum 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.
</p></div>
<div class="col"><p>
Lorem Ipsum is simply dummy text of the printing and
typesetting industry. Lorem Ipsum 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.
</p></div>
</div>
</div>
<div class="oac-r">
<div class="row">
<div class="col">
<p>
Lorem Ipsum is simply dummy text of the printing and
typesetting industry. Lorem Ipsum 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.
</p></div>
<div class="col"><p>
Lorem Ipsum is simply dummy text of the printing and
typesetting industry. Lorem Ipsum 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.
</p></div>
</div>
</div>
</div>
</div>
</div>
</section>

最佳答案

如果将两个一组放在一个额外的 div 中,然后设置顶部和底部边距,它应该会更容易一些。

例如:

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous">
</script>
</head>

<body>
<div class='d-flex justify-content-around'>
<div id='left-column'>
<div>
<p>top left</p>
</div>
<div class='mb-4'>
<p>bottom left</p>
</div>
</div>
<div id='right-column'>
<div class='mt-4'>
<p>top right</p>
</div>
<div>
<p>bottom right</p>
</div>
</div>
</div>
</body>

</html>

关于css - 以特定效果对齐列(右/左),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58368570/

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