我希望我的网站有 md 大小的屏幕,右侧有更大的手机,左侧有文本。但是一旦屏幕尺寸小于 md,我希望文本在手机下方。
<section id="" class="pt-3 mt-3">
<div class="container">
<div class="row">
<div class="col-md-6 my-auto text-right">
<h3 class="display-3 lato_text">Description</h3>
<p class="lead">On the map, click on an OddJob to get a quick preview.</p>
<p class="lead">In the preview, you will see the title and price of the job.</p>
</div>
<div class="col-md-6">
<div class="text-center">
<img id="phone-screenshot" src="img/JobFullDesc.jpg" class="img-fluid mb-3">
</div>
</div>
</div>
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
我将如何更改我的 html 以使其在 md 大小的屏幕及以下屏幕上,文本将位于手机下方。
您可以使用 Bootstrap 4 的order类。
不幸的是,Bootstrap 4 的布局类是移动优先的,因此您需要指定默认情况下文本应该在图像之后,并 在大屏幕上覆盖它。
要在中型和小型设备上将文本放在图像下方,您需要为文本提供类order-2和order-md-1,为图像提供类order-1和order-md-2。
这可以在以下内容中看到:
<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>
<section id="" class="pt-3 mt-3">
<div class="container">
<div class="row">
<div class="col-md-6 my-auto text-right order-2 order-md-1">
<h3 class="display-3 lato_text">Description</h3>
<p class="lead">On the map, click on an OddJob to get a quick preview.</p>
<p class="lead">In the preview, you will see the title and price of the job.</p>
</div>
<div class="col-md-6 order-1 order-md-2">
<div class="text-center">
<img id="phone-screenshot" src="http://placehold.it/100" class="img-fluid mb-3">
</div>
</div>
</div>
</div>
</section>Run Code Online (Sandbox Code Playgroud)
请注意,在小屏幕上(例如在默认视图中使用此代码段),图像在文本之前,而在较大屏幕上(如在Full page视图中使用此代码段),图像在文本之后。
| 归档时间: |
|
| 查看次数: |
2680 次 |
| 最近记录: |