我正在学习CSS,正在集成设计模板(PSD)。
我陷入了一个小问题,必须对齐 4列,左侧的 2 和右侧的 2 ...
问题在于,右侧的2列应该在左侧的2列下方一点。( 查看图片 )< / p>
我正在寻找解决方案...但是找不到精确地我要找的东西。
我尝试了很多东西(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>
答案 0 :(得分:1)
如果您将两个一组放在一个额外的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>
答案 1 :(得分:0)
您当然可以通过引导程序或任何其他方式显示它。 在引导程序中,您可以使用以下代码:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="col">
<div>
Title one
</div>
<div>
Title two
</div>
</div>
<div class="col">
<br />
<div>
Title three
</div>
<div>
Title four
</div>
</div>
</div>
</div>
<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>