CSS 响应图像定位在图像上
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16363029/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Responsive images positioned over image
提问by dclawson
I have setup a jsfiddle of what i'm trying to do:
我已经设置了我正在尝试做的 jsfiddle:
http://jsfiddle.net/MgcDU/3936/
http://jsfiddle.net/MgcDU/3936/
#counter {
position: relative;
}
#over {
position:absolute;
left:33%;
top:43%;
}
The image of the cat is my background image which resizes as the browser resizes.
猫的图像是我的背景图像,它会随着浏览器的大小调整大小。
The ball image is absolutely positioned over the cat. How can I get the ball image to resize and stay in the same position as it is my default?
球图像绝对位于猫上方。如何让球图像调整大小并保持与默认位置相同的位置?
回答by Marcel Gwerder
Set your #counter
div to display: inline;
or add a wrapper with display: inline;
and set the max-width
of #over
to for example 10%
(DEMO):
您设置#counter
股利display: inline;
或增加包装与display: inline;
和设置max-width
的#over
为例子10%
(DEMO):
#counter {
position: relative;
display: inline;
}
#over {
position:absolute;
left:33%;
top:43%;
max-width: 10%;
}