Html 引导卡没有像示例中那样显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37930480/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap cards not showing like in examples
提问by flex_
Why do my Bootstrap cards look weird? In the examples they look like cards with a border and white padding but mine look like text only without the padding and the white background.
为什么我的 Bootstrap 卡看起来很奇怪?在示例中,它们看起来像带有边框和白色填充的卡片,但我的看起来像没有填充和白色背景的文本。
For example:
例如:
I don't know if the code will help you but here it is:
我不知道代码是否会帮助你,但这里是:
.container {
left: 0;
right: 0;
bottom: -340px;
text-align: middle;
position: absolute;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="card">
<img class="card-img-top" src="http://www.themdfactor.com/wp-content/uploads/2015/09/card1.jpg" alt="Card image cap">
<div class="card-block">
<h4 class="card-title">This is Card #1</h4>
<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>
<a href="http://v4-alpha.getbootstrap.com/components/card/" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>
</div>
</div>
回答by vallismortis
The Bootstrap 4 cardfeature has undergone additional changes from the earlier v4-alpha version(s) to the v4-beta version. However, the examples on the Bootstrap web site still use the older class name. The cards still render, but the padding is lost if the older class name is used.
从早期的 v4-alpha 版本到 v4-beta 版本,Bootstrap 4 卡功能发生了额外的变化。但是,Bootstrap 网站上的示例仍然使用旧的类名。卡片仍然呈现,但如果使用旧的类名,填充会丢失。
Current (September 2017) example using the card-body
class (CSS):
当前(2017 年 9 月)使用card-body
类 ( CSS) 的示例:
<div class="card" style="width: 20rem;">
<img class="card-img-top" src="..." alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<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>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
Here is a similar answerto a related question.
回答by Rachel S
It shows up fine by me. You have to make sure that you are linking the version 4 style sheet.
它在我看来很好。您必须确保链接的是第 4 版样式表。
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
回答by cevaris
Copying card css from the boostrap4 version into your bootstrap3 solution worked for me. Nice if you are stuck on bootstrap3.
将卡 css 从 boostrap4 版本复制到您的 bootstrap3 解决方案中对我有用。如果你被困在 bootstrap3 上,那就太好了。
Just drop the following in your CSS anywhere.
只需将以下内容放入 CSS 中的任何位置即可。
.card {
position: relative;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
background-color: #fff;
border: 1px solid rgba(0, 0, 0, 0.125);
border-radius: 0.25rem;
}
.card-block {
-webkit-box-flex: 1;
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
padding: 1.25rem;
}
.card-title {
margin-bottom: 0.75rem;
}
.card-subtitle {
margin-top: -0.375rem;
margin-bottom: 0;
}
.card-text:last-child {
margin-bottom: 0;
}
.card-link:hover {
text-decoration: none;
}
.card-link + .card-link {
margin-left: 1.25rem;
}
.card > .list-group:first-child .list-group-item:first-child {
border-top-right-radius: 0.25rem;
border-top-left-radius: 0.25rem;
}
.card > .list-group:last-child .list-group-item:last-child {
border-bottom-right-radius: 0.25rem;
border-bottom-left-radius: 0.25rem;
}
.card-header {
padding: 0.75rem 1.25rem;
margin-bottom: 0;
background-color: #f7f7f9;
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}
.card-header:first-child {
border-radius: calc(0.25rem - 1px) calc(0.25rem - 1px) 0 0;
}
.card-footer {
padding: 0.75rem 1.25rem;
background-color: #f7f7f9;
border-top: 1px solid rgba(0, 0, 0, 0.125);
}
.card-footer:last-child {
border-radius: 0 0 calc(0.25rem - 1px) calc(0.25rem - 1px);
}
.card-header-tabs {
margin-right: -0.625rem;
margin-bottom: -0.75rem;
margin-left: -0.625rem;
border-bottom: 0;
}
.card-header-pills {
margin-right: -0.625rem;
margin-left: -0.625rem;
}
.card-primary {
background-color: #0275d8;
border-color: #0275d8;
}
.card-primary .card-header,
.card-primary .card-footer {
background-color: transparent;
}
.card-success {
background-color: #5cb85c;
border-color: #5cb85c;
}
.card-success .card-header,
.card-success .card-footer {
background-color: transparent;
}
.card-info {
background-color: #5bc0de;
border-color: #5bc0de;
}
.card-info .card-header,
.card-info .card-footer {
background-color: transparent;
}
.card-warning {
background-color: #f0ad4e;
border-color: #f0ad4e;
}
.card-warning .card-header,
.card-warning .card-footer {
background-color: transparent;
}
.card-danger {
background-color: #d9534f;
border-color: #d9534f;
}
.card-danger .card-header,
.card-danger .card-footer {
background-color: transparent;
}
.card-outline-primary {
background-color: transparent;
border-color: #0275d8;
}
.card-outline-secondary {
background-color: transparent;
border-color: #ccc;
}
.card-outline-info {
background-color: transparent;
border-color: #5bc0de;
}
.card-outline-success {
background-color: transparent;
border-color: #5cb85c;
}
.card-outline-warning {
background-color: transparent;
border-color: #f0ad4e;
}
.card-outline-danger {
background-color: transparent;
border-color: #d9534f;
}
.card-inverse {
color: rgba(255, 255, 255, 0.65);
}
.card-inverse .card-header,
.card-inverse .card-footer {
background-color: transparent;
border-color: rgba(255, 255, 255, 0.2);
}
.card-inverse .card-header,
.card-inverse .card-footer,
.card-inverse .card-title,
.card-inverse .card-blockquote {
color: #fff;
}
.card-inverse .card-link,
.card-inverse .card-text,
.card-inverse .card-subtitle,
.card-inverse .card-blockquote .blockquote-footer {
color: rgba(255, 255, 255, 0.65);
}
.card-inverse .card-link:focus, .card-inverse .card-link:hover {
color: #fff;
}
.card-blockquote {
padding: 0;
margin-bottom: 0;
border-left: 0;
}
.card-img {
border-radius: calc(0.25rem - 1px);
}
.card-img-overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 1.25rem;
}
.card-img-top {
border-top-right-radius: calc(0.25rem - 1px);
border-top-left-radius: calc(0.25rem - 1px);
}
.card-img-bottom {
border-bottom-right-radius: calc(0.25rem - 1px);
border-bottom-left-radius: calc(0.25rem - 1px);
}
@media (min-width: 576px) {
.card-deck {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
}
.card-deck .card {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-flex: 1;
-webkit-flex: 1 0 0%;
-ms-flex: 1 0 0%;
flex: 1 0 0%;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
}
.card-deck .card:not(:first-child) {
margin-left: 15px;
}
.card-deck .card:not(:last-child) {
margin-right: 15px;
}
}
@media (min-width: 576px) {
.card-group {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
}
.card-group .card {
-webkit-box-flex: 1;
-webkit-flex: 1 0 0%;
-ms-flex: 1 0 0%;
flex: 1 0 0%;
}
.card-group .card + .card {
margin-left: 0;
border-left: 0;
}
.card-group .card:first-child {
border-bottom-right-radius: 0;
border-top-right-radius: 0;
}
.card-group .card:first-child .card-img-top {
border-top-right-radius: 0;
}
.card-group .card:first-child .card-img-bottom {
border-bottom-right-radius: 0;
}
.card-group .card:last-child {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
}
.card-group .card:last-child .card-img-top {
border-top-left-radius: 0;
}
.card-group .card:last-child .card-img-bottom {
border-bottom-left-radius: 0;
}
.card-group .card:not(:first-child):not(:last-child) {
border-radius: 0;
}
.card-group .card:not(:first-child):not(:last-child) .card-img-top,
.card-group .card:not(:first-child):not(:last-child) .card-img-bottom {
border-radius: 0;
}
}
@media (min-width: 576px) {
.card-columns {
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3;
-webkit-column-gap: 1.25rem;
-moz-column-gap: 1.25rem;
column-gap: 1.25rem;
}
.card-columns .card {
display: inline-block;
width: 100%;
margin-bottom: 0.75rem;
}
}
Source: https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L4055
来源:https: //github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L4055
回答by killa-byte
This might be old, but are you using a customized bootstrap file by any chance? I recently was trying to work with cards using our customized file, and the same thing was happening to me. Then I realized that there are no card classes in the bootstrap file, nor is there any mention of Cards on the customize page.
这可能很旧,但是您是否有机会使用自定义的引导程序文件?我最近尝试使用我们的自定义文件处理卡片,同样的事情也发生在我身上。然后我意识到引导文件中没有卡片类,自定义页面上也没有提到卡片。
http://getbootstrap.com/customize/
http://getbootstrap.com/customize/
Seems strange to me, I even had a coworker verify it though. Hope this helps.
对我来说似乎很奇怪,但我什至让一位同事验证了它。希望这可以帮助。
回答by Lawrence_NT
If you have installed bootstrap via a package manager, such as NPM:
如果您通过包管理器安装了引导程序,例如 NPM:
For some package managers, the default installed version is [email protected]
which doesn't appear to have this feature.
对于某些包管理器,默认安装的版本[email protected]
似乎没有此功能。
This could be misleading as the correct version is described on Bootstrap's Getting started > Download section, found here
这可能会产生误导,因为 Bootstrap 的入门 > 下载部分描述了正确的版本,可在此处找到
To resolve, ensure you are referencing the latest package version [email protected]
要解决,请确保您引用的是最新的软件包版本 [email protected]