gpt4 book ai didi

css - 在 Bootstrap 中将 `.img-responsive` 置于 `.container-fluid` 和 `row` 的中心?

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

我不希望这里的答案对 21 世纪对计算机科学的理解有多大帮助,但我很感谢社区的帮助。

我有一个图像,我正试图在 Bootstrap 中居中。它在 .container-fluid 中, 一个 .row , 和一个 .col-xs-6.offset-xs-3 . <img...>本身就是.img-responsive .你可以在这个代码笔上看到这个元素:http://codepen.io/NotAnAmbiTurner/pen/GrGmaq?editors=1000 .

图像未居中 - 我应该能够获得随视口(viewport)宽度(如 SVG)缩放且位于页面中间的图像。我似乎无法做到这一点。

我想知道这是否与我从保管箱中获取“原始”图像作为我的 src 这件事有关, 图像是 .jpg ,或一些组合?话又说回来,我对此一窍不通,所以也有可能只是某个地方有一个我似乎找不到的拼写错误。我浏览了引导文档,各种 SO 问题都无济于事。我找到的唯一解决方案是删除 <img...>来自容器和行,并分配 ... class="centered-block" ... .但是,除非我从根本上误解了某些东西,否则 (1) 我不应该那样做,并且 (2) 我不想一头雾水,而是想了解在任何情况下我的概念错误是什么,以供我自己学习。

PS - 完全不相关,但我的 <a ...></a>标签似乎不可点击。如果有人对此有任何想法,那也很好。

事实证明,基本问题是 CodePen 依赖于 Bootstrap 4,而不是(如我所假设的那样)Bootstrap 3

最佳答案

您正在使用来自 Bootstrap 3 的类,但加载来自 Bootstrap 4 的样式表;它们不全面兼容。 img-responsive 以及 col-xs-* 类不再存在。参见 ImagesGrid Options .

注意:您的链接将无效,因为它们不是有效的 HTML,并且您还用 h3 关闭了 h2,validate你的标记。

工作示例:

@media (max-width: 480px) {
h1 {
font-size: 5vmax;
}
h2 {
font-size: 3.5vmax;
}
h3 {
font-size: 2.5vmax;
}
li {
font-size: 2.5vmax;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />

<div class="jumbotron">

<h1 class="text-primary">Dr. Clair Cameron Patterson</h1>

<h2 class="text-secondary">The man who first learned the age of the Earth, and helped save a civilization from the dangers of its use of lead.</h2>

<div class="container-fluid">
<div class="row">
<div class="col">
<img src="https://www.dropbox.com/s/91fw6aazyxzb178/image-for-codecamp-tribute-page.jpg?raw=1" alt="Cartoon Image of Clair Cameron Patterson at Congressional Hearing" class="img-fluid mx-auto d-block" style="padding:1.5vmin">
</div>
</div>
</div>

<h3>Academics</h3>
<ul>
<li>Undergraduate, Grinnell College</li>
<li>PhD, University of Chicago</li>
<li>Researcher, California Institute of Technology</li>
</ul>

<h3>Brief Timeline</h3>

<ul>
<li><strong>1956</strong>: found the earth to be 4.55 Billion years old using <a href="https://en.wikipedia.org/wiki/Lead%E2%80%93lead_dating">lead-lead dating</a> and
<a href="https://en.wikipedia.org/wiki/Canyon_Diablo_(meteorite)">a fragment of a metorite that fell in Arizona</a>. This calculation has been largely undisturbed since.</li>
<li><strong>1965</strong>: began campaign against lead in various products, especially gasoline, which at that time was emitting lead into the atmosphere.</li>
<li><strong>1978</strong>: wrote a 78-page minority opinion as part of a National Research Council (NRC) panel stating that controls on lead in various products had to start immediately, including gasoline, food containers, paint, glazes, and water distribution
systems.
</li>
<li>by the late <strong>1990s</strong>: levels of lead in Americans' blood has dropped by up to 80%. Though connections with Dr. Patterson's work are not clear, as the leading researcher in the area, and constant campaigner against the use of lead, it
is likely he was a major antecedant of this change.</li>
</ul>

</div>

关于css - 在 Bootstrap 中将 `.img-responsive` 置于 `.container-fluid` 和 `row` 的中心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42057580/

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