我需要使用CSS居中的图像内的按钮,但我不能够相对于中间的按钮图像围绕按钮图像与CSS
这里的左上角是页面
HTML文件:
<div class="content">
<img class="mainImage" src="http://mintywhite.com/wp-content/uploads/2012/10/fond-ecran-wallpaper-image-arriere-plan-hd-29-HD.jpg" alt="logo">
<div id="startButton">
<button onclick="hide()" width="40px">Start Now</button>
</div>
</div>
CSS:
.content{
position: relative;
}
img.mainImage{
position: relative;
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 50px;
width: auto;
height: auto;
max-width: 400px;
max-height: 500px;
visibility: visible;
z-index: 1;
}
#startButton{
position: absolute;
margin-left: auto;
margin-right: auto;
top: 0px;
left: 0px;
z-index: 2;
}
body{
background-image: url('http://www.psdgraphics.com/file/colorful-triangles-background.jpg');
margin: 0;
padding: 0;
}
我需要的东西,它如同按钮 http://www.whatsapp.com/
“下载Whataspp”在这里我需要就像一个当你一个按钮重新调整窗口大小,即它不具有相对移动其背景图像
http://jsfiddle.net/3j5w5v7f/2/ ..这是你在找什么? ..或让我知道你想要按钮的位置是 – 2014-11-03 21:58:21
如果你想使用坐标来居中它,那么它就不是你需要的东西http://jsfiddle.net/3j5w5v7f/5/ – waplet 2014-11-03 22:01:09
你能澄清吗?你想让开始按钮相对于#mainImage定位吗? – hungerstar 2014-11-03 22:01:36