如果要居中的DIV按钮,同时有一个背景图像的DIV。我会建议,为div分配一个背景图像,而不是插入图像到div中。退房小提琴:
http://jsfiddle.net/49s505sa/1/
HTML:
<div id="wrapper">
<button type="button">Your Button</button>
</div>
CSS:
#wrapper {
width: 100%;
height: 400px;
border: 1px solid black;
background: url('http://placehold.it/350x150') /*assign image, for demo purposes */
}
button {
height: 20px;
position: relative;
margin: -20px -50px;
width: 100px;
top: 50%;
left: 50%;
}
所以,里面的渲染方法
var style = {
backgroundImage: 'url(' + album.photos.data[0].source+ ')'
}
<div className={"panel-body"} style={style}>
{(this.state.isMouseInsideID === album.id) ? <button>Your Button</button> : null}
</div>
这样,我们将动态分配图像到特定的div。而且不必太担心造型。
希望有帮助!
使用CSS,相对或绝对位置,你想要的按钮,它 –
作为@JaromandaX提到的,设置一个相对/绝对具有正确的z-index,应该做这个我试过'.mynew-BTN { 位置工作 –