gpt4 book ai didi

javascript - Bootstrap 容器未正确对齐

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

我最近使用 bootstrap 来帮助我调整我网站上的元素组合。当然,除了我在手机上运行网站时,它确实达到了我的预期。我在每个 div 元素上使用容器以将其保留在区域内,但结果完全不同。

如果我在桌面浏览器中运行手机模拟器,它会显示预期的结果,但是,如果我在真实手机中运行它,结果就会一团糟。

我网站的链接是- www.ijatin.ca 并访问其中的元素部分并尝试在手机模拟器上运行,在真实手机上你会看到 2 个不同的结果。谁能告诉我,为什么会有这样的差异,我该如何克服呢?非常感谢

最佳答案

我看到你已经使用了 Bootstrap 4,最好的用法应该是这样的,
container -> [row -> col-* -> card] [row -> col-* -> card] [row -> col-* -> card] 容器结束

但是在你的代码中
container -> [row -> col-* -> card] 容器结束,container -> [row -> col-* -> card] 容器结束,container -> [row -> col-* -> card] 容器结束

您不必为每一行都有一个容器 div。容器 div 可以作为父级放置,您希望将子元素放置在 Bootstrap 特定宽度内。所以我建议像下面这样更改您的代码

<article id="work" style="display: block;" class="active">

<div class="container">
<h2 class="major">Projects</h2>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12"> <!-- change column size according to your need -->
<div class="card project-section">
<img class="card-img-top project-image" src="images/pic02.jpg" alt="Card image cap">
<div class="card-body">
<h3 class="card-title project-card-header">Emaily- collecting survey made easy</h3>
<p class="card-text">
Developed a Survey application for smaller businesses who have less resources to create their own. Upon registering on the website, user will be able to send emails to their customers to provide a feedback. The result from the feedback will displayed
on the dashboard.

</p>
<div class="row">
<a href="https://github.com/Jatin-007/Emaily" target="_blank" class="btn btn-primary project-button"><span class="icon fa-github"> Github</span></a>
<a href="#" class="btn btn-primary project-button disabled"><span class="icon far fa-desktop"> Website</span></a>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="card project-section">
<img class="card-img-top project-image" src="images/pic02.jpg" alt="Card image cap">
<div class="card-body">
<h3 class="card-title project-card-header">Emaily- collecting survey made easy</h3>
<p class="card-text">
Developed a Survey application for smaller businesses who have less resources to create their own. Upon registering on the website, user will be able to send emails to their customers to provide a feedback. The result from the feedback will displayed
on the dashboard.

</p>
<div class="row">
<a href="https://github.com/Jatin-007/Emaily" target="_blank" class="btn btn-primary project-button"><span class="icon fa-github"> Github</span></a>
<a href="#" class="btn btn-primary project-button disabled"><span class="icon far fa-desktop"> Website</span></a>
</div>
</div>
</div>
</div>
</div>

<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="card project-section">
<img class="card-img-top project-image" src="images/pic02.jpg" alt="Card image cap">
<div class="card-body">
<h3 class="card-title project-card-header">Emaily- collecting survey made easy</h3>
<p class="card-text">
Developed a Survey application for smaller businesses who have less resources to create their own. Upon registering on the website, user will be able to send emails to their customers to provide a feedback. The result from the feedback will displayed
on the dashboard.

</p>
<div class="row">
<a href="https://github.com/Jatin-007/Emaily" target="_blank" class="btn btn-primary project-button"><span class="icon fa-github"> Github</span></a>
<a href="#" class="btn btn-primary project-button disabled"><span class="icon far fa-desktop"> Website</span></a>
</div>
</div>
</div>
</div>
</div>
</div>

<div class="container offset-lg-1 row">
<div class="card col-md-7 col-sm-12 offset-md-2 offset-lg-2 float-left project-section" style="width: 18rem;">
<img class="card-img-top project-image" src="images/pic02.jpg" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<div class="row">
<a href="https://github.com/Jatin-007/Emaily" target="_blank" class="btn btn-primary project-button"><span class="icon fa-github"> Github</span></a>
<a href="#" class="btn btn-primary project-button disabled"><span class="icon far fa-desktop"> Website</span></a>
</div>
</div>
</div>
</div>

<div class="container offset-lg-1 row">
<div class="card col-sm-12 col-lg-7 flaot-right project-section" style="width: 18rem;">
<img class="card-img-top project-image" src="images/pic02.jpg" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<div class="row">
<a href="https://github.com/Jatin-007/Emaily" target="_blank" class="btn btn-primary project-button"><span class="icon fa-github"> Github</span></a>
<a href="#" class="btn btn-primary project-button disabled"><span class="icon far fa-desktop"> Website</span></a>
</div>
</div>
</div>
</div>

<div class="container col-sm-12 offset-lg-1 row">
<div class="card col-md-7 col-sm-12 offset-md-2 offset-lg-2 float-left project-section" style="width: 18rem;">
<img class="card-img-top project-image" src="images/pic02.jpg" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<div class="row">
<a href="https://github.com/Jatin-007/Emaily" target="_blank" class="btn btn-primary project-button"><span class="icon fa-github"> Github</span></a>
<a href="#" class="btn btn-primary project-button disabled"><span class="icon far fa-desktop"> Website</span></a>
</div>
</div>
</div>
</div>
<div class="close">Close</div>
</article>

这看起来像 enter image description here

希望这对您有所帮助!

关于javascript - Bootstrap 容器未正确对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49961060/

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