Html 当div的大小增加时,如何使图像本身居中
我正在努力修复弹出窗口中的图像,我的问题是图像被拉伸到整个div 我正在应用的div是从JQuery获取宽度和高度。 HTMLHtml 当div的大小增加时,如何使图像本身居中,html,css,Html,Css,我正在努力修复弹出窗口中的图像,我的问题是图像被拉伸到整个div 我正在应用的div是从JQuery获取宽度和高度。 HTML 尝试将位置添加到.about滑块容器中 .about-slider-container { position: relative; //or something that suits you top: 0; left: 0; right: 0; bottom: 0; padding: 25px; z-index: 100; } #portf
尝试将位置添加到.about滑块容器中
.about-slider-container {
position: relative; //or something that suits you
top: 0;
left: 0;
right: 0;
bottom: 0;
padding: 25px;
z-index: 100;
}
#portfolio-detail {
position: absolute;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.9);
z-index: 9999;
}
只是好奇。您的代码与jquery的关系如何?当您说“拉伸”时,是不是意味着它失去了纵横比?如果是这样,您是否希望它拉伸到可用宽度,但仍保留该纵横比?首先,我要删除高度属性。@Vikram,你想用class=“folioimg”或class=“portfolio close”将哪个图像居中,然后是。。。@DmitryPoroh的观点很好-这里没有jQuery:)
.about-slider-container {
top: 0;
left: 0;
right: 0;
bottom: 0;
padding: 25px;
z-index: 100;
}
#portfolio-detail {
position: absolute;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.9);
z-index: 9999;
}
.about-slider-container {
position: relative; //or something that suits you
top: 0;
left: 0;
right: 0;
bottom: 0;
padding: 25px;
z-index: 100;
}
#portfolio-detail {
position: absolute;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.9);
z-index: 9999;
}