Html 使用引导使图像垂直和水平居中
我有一个页面,它使用bootstrap显示内容,我得到了大部分关于我想要它的位置的信息,除了我的图像,即使垂直居中,也不是水平居中Html 使用引导使图像垂直和水平居中,html,css,bootstrap-4,Html,Css,Bootstrap 4,我有一个页面,它使用bootstrap显示内容,我得到了大部分关于我想要它的位置的信息,除了我的图像,即使垂直居中,也不是水平居中 我试图使这样做,如果有人添加了一个小的图像或一个巨大的图像,它总是包含在列/行中,并响应于该容器,但我也要确保,如果图像小于容器,它完全位于容器的中间。 我在这里遗漏了什么来确保图像居中对齐,除非另有规定 html, body { height: 100vh; width: 100vw; overflow: hid
我试图使这样做,如果有人添加了一个小的图像或一个巨大的图像,它总是包含在列/行中,并响应于该容器,但我也要确保,如果图像小于容器,它完全位于容器的中间。
我在这里遗漏了什么来确保图像居中对齐,除非另有规定 html,
body {
height: 100vh;
width: 100vw;
overflow: hidden;
}
iframe{
height:100% !important;
width:100% !important;
}
.middle p{
max-height:100%;
}
img {
max-width: 100%;
height:auto;
margin:0 auto;
}
.my-container {
display: flex;
flex-direction: column;
justify-content: center;
height: 100vh;
width:100vw;
}
.my-container>.top [class^="col-"],
.my-container>.bottom [class^="col-"] {
background-color: #778899 ;
color: white;
text-align: center;
}
.my-container>.middle {
flex-grow: 1;
padding:30px;
/*background-image: url('images/bg_green.svg');*/
background-size: cover;
}
<div class="row middle" id="middle" style="background-image: url();">
<div class="col-lg-12" id="fullColumn">
<div class="fullContent" id="fullContent" style="height: 100%; ">
</div>
</div>
</div>
您试过了吗
显示:块
为了形象
如果你能给出一张你想要存档的布局图,那会很有帮助。你试过了吗
显示:块
为了形象
如果你能提供一张你想要存档的布局图,它会有帮助,请查看下面的链接。这可能对你有帮助。我已将flex属性添加到父分区。谢谢
输入
请检查下面的链接。这可能对你有帮助。我已将flex属性添加到父分区。谢谢
输入
您可以通过添加类别col-lg-3而不是col-lg-12使图像居中,并赋予div标记样式为margin:0px auto使其居中
<div class="col-lg-3" id="fullColumn" style="margin: 0px auto;">
<div class="fullContent" id="fullContent" style="height: 100%; ">
</div>
</div>
您可以通过添加col-lg-3类而不是col-lg-12类,使图像居中,并将div标记样式设置为margin:0px auto以使其居中
<div class="col-lg-3" id="fullColumn" style="margin: 0px auto;">
<div class="fullContent" id="fullContent" style="height: 100%; ">
</div>
</div>
不幸的是,这没有解决问题,但我在问题上方添加了一个图像不幸的是,这没有解决问题,但我在问题上方添加了一个图像,得到了它,谢谢!对不起,事实上:我刚刚在上面添加了一个包含多个div的更新,你能告诉我为什么它不适用于这些div吗?这些图像没有居中或中间对齐。(点)用于类,而#(散列)用于id。将点更改为#,可以使用。谢谢收到了,谢谢!对不起,事实上:我刚刚在上面添加了一个包含多个div的更新,你能告诉我为什么它不适用于这些div吗?这些图像没有居中或中间对齐。(点)用于类,而#(散列)用于id。将点更改为#,可以使用。谢谢
<div class="col-lg-3" id="fullColumn" style="margin: 0px auto;">
<div class="fullContent" id="fullContent" style="height: 100%; ">
</div>
</div>