显示不同高度图像的流体 div 的垂直对齐
好吧..这就是交易。我一直在修改不久前购买的 WordPress 主题,但遇到了困难。 不幸的是,我不懂 CSS。我可以调整一些东西,但我怀疑我是否能够自己解决这个问题。所以,这里是一个求助:)
网站和 div 的代码如下: http://photography.hamsterwheelproject.com/category/photo-of-the-day/
element.style {
overflow: hidden;
z-index: 0;
position: fixed;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
display: block;
}
#superbgimage img {
position: static !important;
height: auto !important;
width: 100% !important;
top: 0 !important;
margin: 0 auto;}
这个想法是让图像始终垂直居中显示。我想将宽度保持为 100% 并水平填充屏幕,同时保持照片的纵横比。
谢谢!
Alright.. here's the deal. I've been modifying a WordPress theme I purchased a while ago and I've hit a wall.
Unfortunately, I'm not CSS literate. I can adjust stuff, but I doubt I will be able to solve this on my own. So, here's a cry for help :)
The website and the div's code are bellow: http://photography.hamsterwheelproject.com/category/photo-of-the-day/
element.style {
overflow: hidden;
z-index: 0;
position: fixed;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
display: block;
}
#superbgimage img {
position: static !important;
height: auto !important;
width: 100% !important;
top: 0 !important;
margin: 0 auto;}
The idea is to have the images always displayed vertically centered. I'd like to keep the width to 100% and fill the screen horizontally, while maintaining the photos' aspect ratio.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你可以给你的容器一个固定的高度,那么使用CSS就很容易:
如果你不能在CSS中设置固定的高度,你可以很容易地使用JQuery(或任何其他javascript解决方案)动态设置它:
If you can give your container a fixed height, it's easy with CSS:
If you can't set a fixed height in your CSS, you can set it dynamically with JQuery (or any other javascript solution) quite easily: