【发布时间】:2021-03-05 21:17:23
【问题描述】:
我在对齐两列网格中的项目时遇到了一些问题。如果您查看this picture,您会发现这些项目没有正确对齐。您会注意到“示例 3”与“示例 4”不一致。我认为问题在于,由于“示例 2”没有描述,“示例 3”占据了“示例 2”的空白区域。
即使没有任何示例的描述,“示例 1”也应该与“示例 2”(第 1 行)对齐。 “示例 3”应与“示例 4”(第 2 行)对齐。 It should be like this.
我不确定是什么导致了这种错位。我不确定我的引导程序是否错误。我正在使用 Col-sm-6 Col-md-6 。这是我的代码:
<div class="myTree">
<div class="col-sm-6 col-md-6">
@if(link !=null) // if link is there, then it shoud apply to image and title.
{
<a href="@link.URL" title="@link.LinkName" target="@link.TargetWindow">
<div class="content">
<div class="treeimagewithLink">
<img class="treeimage" alt="@image.GetAttributeValue("AlternateText")" title="@image.GetAttributeValue("AlternateText")" src="images/@image.Value" />
</div>
<div class="treeTitle">
<h3>@title</h3>
</div>
</div>
</a>
<div class="treeexcerpt">
<p>@Html.Raw(Model.GetElementValue("description"))</p>
</div>
}
else{ // if there is no link
<div class="imagewithnoLink">
<img class="treeimage" alt="@image.GetAttributeValue("AlternateText")" title="@image.GetAttributeValue("AlternateText")" src="images/@image.Value" />
</div>
<div class="treeTitle">
<h3>@title</h3>
</div>
<div class="treeexcerpt">
<p>@Html.Raw(Model.GetElementValue("description"))</p>
</div>
}
</div>
</div>
【问题讨论】:
-
我建议您使用 Tailwind Css 并查看这个很棒的视频 Tailwind Labs 如果您不需要使用引导程序。它更容易,反应更灵敏
-
示例 1 和示例 2 都应该放在同一个
<div class="row"> ... </div>中,示例 4 和示例 3 也应该相同。这将确保 1 和 2 保持在同一行,而 3 和 4 保持在同一行另一排。更多信息:getbootstrap.com/docs/4.0/layout/grid -
能否请您发布呈现的 HTML 而不是模板,这使得重现问题变得困难?
标签: html css twitter-bootstrap twitter-bootstrap-3