gpt4 book ai didi

html - 使用 Bootstrap 在背景上垂直居中卡

转载 作者:太空宇宙 更新时间:2023-11-03 22:20:38 25 4
gpt4 key购买 nike

只是为了在标记为转贴之前说清楚,这一切都行不通: How to center cards in bootstrap 4? How to align an image dead center with bootstrap Centering the image in Bootstrap How can I center an image in Bootstrap? How do I center an image in Bootstrap? How to align a <div> to the middle (horizontally/width) of the page How to horizontally center a <div>?

话虽如此,我的问题很简单,我有两个 div,来自 bootstrap 的背景 div 和卡片 div。 mx-auto 将垂直居中就好了,但是不可能从卡的顶部取消固定。这样我在卡的上方和下方也有空间。我试过所有的 m 和 p 类。以及自定义类。有人可以帮帮我吗?我希望我的卡片位于屏幕中间。

<div class="bg">
<div class="card card-design success-design mx-auto">
<div class="card-body">

现在看起来像这样:

ooooxxxoooo
ooooxxxoooo
ooooooooooo
ooooooooooo

我愿意:

ooooooooooo
ooooxxxoooo
ooooxxxoooo
ooooooooooo

最佳答案

试试这个:

body, html {
height: 100%;
}

h3, h4, p, a, label {
color: #001f3f;
}

.bg {
/* The image used */
background-image: url('exemple.png');

/* Full height */
height: 100%;

/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
/* i added following code */
display:flex;
justify-content:center;
align-items:center;
}

.card-design {
background-color: rgba(245, 245, 245, 0.7);
width: 23rem;
font-family: 'Roboto', sans-serif;
font-weight: 300;
border-radius: 0 !important;
}

.success-design {
background-color: rgba(245, 245, 245, 0.8);
}

.nbr-apt {
font-size: 220%;
font-weight: 100;
}

.rdv {
font-size: 160%;
}

.num {
font-weight: bold;
<body>
<div class="bg">
<div class="card card-design success-design mx-auto">
<div class="card-body">
<h3 class="card-title"> bla bla bla</h3>
<h4 class="card-subtitle mb-2 text-muted"> bla bla bla</h4>
<h4 class="card-subtitle mb-2 text-muted"> bla bla blam</h4>
<br>
<br>
<p class="card-text nbr-apt">Merci bla bla bla</p>
</div>
</div>
</div>
</body>

关于html - 使用 Bootstrap 在背景上垂直居中卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54051606/

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