![](/img/trans.png)
[英]How can I put the HTML5 button CSV just above at the top-right corner of the datatable
[英]How can I move the close button to the top-right corner of the box in slimbox (jQuery)
我想將按鈕放在右上角,我嘗試了position:absolute,但是我認為盒子的位置不是相對的,所以我不能使用top:0;。
有什么建議么?
CSS:
/* SLIMBOX */
#lbOverlay {
position: fixed;
z-index: 9999;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: #000;
cursor: pointer;
}
#lbCenter, #lbBottomContainer {
position: absolute;
z-index: 9999;
overflow: hidden;
background-color: #fff;
}
.lbLoading {
background: #fff url(slimbox2/loading.gif) no-repeat center;
}
#lbImage {
position: absolute;
left: 0;
top: 0;
border: 10px solid #fff;
background-repeat: no-repeat;
}
#lbPrevLink, #lbNextLink {
display: block;
position: absolute;
top: 0;
width: 50%;
outline: none;
}
#lbPrevLink {
left: 0;
}
#lbPrevLink:hover {
background: transparent url(slimbox2/prevlabel.gif) no-repeat 0 15%;
}
#lbNextLink {
right: 0;
}
#lbNextLink:hover {
background: transparent url(slimbox2/nextlabel.gif) no-repeat 100% 15%;
}
#lbBottom {
font-family: Verdana, Arial, Geneva, Helvetica, sans-serif;
font-size: 10px;
color: #666;
line-height: 1.4em;
text-align: left;
border: 10px solid #fff;
border-top-style: none;
}
#lbCloseLink {
display: block;
float: right;
width: 31px;
height: 32px;
background: transparent url(slimbox2/closelabel.gif) no-repeat center;
margin: 5px 0;
outline: none;
}
#lbCloseLink:hover {
background: transparent url(slimbox2/closelabel_hover.gif) no-repeat center;
border-bottom: 0px;
}
#lbCaption, #lbNumber {
margin-right: 71px;
}
#lbCaption {
font-weight: bold;
}
按鈕#lbCloseLink
是內部#lbBottomContainer
,這是絕對定位。
您可以嘗試在按鈕上使用margin-top: -Npx
,但是要執行此操作,您必須知道內容的高度並消除overflow: hidden
在#lbBottomContainer
。 另一個解決方案可能是修補Slimbox並將按鈕放入#lbCenter
。
我編輯了slimbox.js(首先使用: http ://jsbeautifier.org/擴展了腳本)和slimbox.css。
1)編輯slimbox.js
I.setStyles({
width: N,
top: O, /* modified for TOP POSITION; original was O+t */
marginLeft: -N / 2,
visibility: "hidden",
display: ""
});
b.setStyles({
overflow:"visible", /* new line inserted for visibility TOP POSITION */
top: Math.max(0, z - (t / 2)),
width: N,
height: t,
marginLeft: -N / 2,
display: ""
});
2)編輯slimbox.css
#lbBottom {
font-family: Verdana, Arial, Geneva, Helvetica, sans-serif;
font-size: 10px;
color: #666;
line-height: 1.4em;
text-align: left;
border-right: 10px solid #fff; /* modified: line inserted for TOP POSITION */
border-left: 10px solid #fff; /* modified: line inserted for TOP POSITION */
}
#lbCloseLink {
display: block;
float: right;
width: 66px;
height: 22px;
background: transparent url(closelabel.gif) no-repeat center;
margin:0 0 0 0; /* modified for TOP POSITION */
outline: none;
}
#lbCaption, #lbNumber {
margin-right: 71px;
margin-top:7px; /* line inserted for TOP POSITION */
}
根據版本2.05,您需要將lbCloseLink插入lbCenter div; 這可以通過減少
w('<a id="lbCloseLink" href="#" />').click(C)[0],
並將其附加到具有相對位置的未命名div
g=w('<div id="lbImage" rel=""/>').appendTo(a).append(p=w('<div style="position: relative;" />').append([w('<a id="lbCloseLink" href="#" />').click(C)[0],I=w('<a id="lbPrevLink" href="#" />').click(B)[0],d=w('<a id="lbNextLink" href="#" />').click(e)[0]])[0])[0];c=w('<div id="lbBottom" />').appendTo(G).append([A=w('<div id="lbCaption" />')[0],K=w('<div id="lbNumber" />')[0],w('<div style="clear: both;" />')[0]])[0];
之后,您需要自定義slimbox2.css,將lbCloselink位置的絕對值和z-index設置為大於1,還可以刪除float:right; 因為浮動具有絕對位置,所以無效
#lbCloseLink {
position: absolute;
right:0px;
z-index: 2;
display: block;
width: %yourwidth%;
height: %yourheight%;
background: transparent url(closelabel.gif) no-repeat center;
outline: none;}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.