简体   繁体   English

弹出图像右上角的定位关闭按钮

[英]Positioned close button in the top right of a pop up image

How can I get the close button [x] http://bit.ly/uHrh3E in the top right handside of the pop up image? 如何在弹出图像的右上方显示关闭按钮[x] http://bit.ly/uHrh3E

    #shDisplay #shWrap #imgContainer {
    position:relative;
}


#shDisplay #shWrap #imgContainer > #clbtn >a {
    font-size:18px;
    margin-bottom:10px;
    color:#fff;
    text-align:right;
    right: 1%;
}

#shShutter *, #shDisplay * {
    padding: 0;
    margin: 0;
}
#clbtn{
    position: absolute; top: 0; right: 0;
    margin-bottom:10px;
}

D.innerHTML = '<div id="shWrap"><div id="imgContainer"><div id="clbtn">' + closebtn + '</div><img src="'+shutterLinks[ln].link+'" id="shTopImg" title="' + t.msgClose + '" onload="shutterReloaded.showImg();" onclick="shutterReloaded.hideShutter();" /></div>' + NavBar +'</div>';

I can't seem to get it working right. 我似乎无法让它正常工作。

Its relative simple, so if you put your button inside the div that contains the image, put on position: relative; 它相对简单,所以如果你把你的按钮放在包含图像的div里面,放在position: relative; on the container, and position: absolute; top: 0; right: 0; 在容器上, position: absolute; top: 0; right: 0; position: absolute; top: 0; right: 0; on your [X] . 在你的[X]

Using position: relative on a container will make child elements be relative to that element, which can be quite handy - like for this particular example. 在容器上使用position: relative将使子元素相对于该元素,这可能非常方便 - 就像这个特定的例子一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM