将此div定位在其容器的中心? [英] Position this div in the center of it's container?
问题描述
在尝试解决之前,请仔细阅读我正在处理的约束。
Before you attempt to solve this please carefully read the constraints I'm dealing with.
约束
Constraints
-
.pictureContainer
需要保留位置:相对
(因为我有一个悬停菜单位置绝对相对于它。)
.pictureContainer
needs to remainposition: relative
(because I have a hover menu that positions absolutely relative to it.)
图像可能小于80 %of #slide
在这种情况下,它仍然必须在中心对齐。这是什么翻译?你不能简单地做一个 margin:0 10%
,因为是的,这将集中这种特定情况,但不会满足图像小于80%宽度 #slide
The image could be smaller than 80% of #slide
in which case it still must align in the center. What this translates to? You can't simply do a margin: 0 10%
because yes that would center this specific case, but it will not satisfy the case where the image is smaller than 80% of the width of #slide
b
$ b你好,我是inline-block元素,位于另一个内联块元素旁边,是不是很精彩?我认为这是美好的!
Hello, I am inline-block element that is positioned beside another inline block element, isn't that wonderful? I think that is wonderful!
推荐答案
不是简单添加:
text-align: center;
到pictureContainer css声明。它会将其中的任何图片。
to pictureContainer css declaration. It will center any image in it.
这篇关于将此div定位在其容器的中心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!