Reputation: 1
I need to align the close button on the Top right of the image. I have tried to give the position but its not taking with the css.
.lb-closeContainer {
position: absolute;
top: -10px;
right:40px;
}
For the actual result, I have attached the image with it.
Upvotes: -1
Views: 3336
Reputation: 625
a.lb-close {
position: absolute;
top: -30px;
right: 0;
}
div#lightbox {
width: auto;
left: 50% !important;
transform: translateX(-50%);
}
For another solution, You can explore this code on CodePen by following this link: https://codepen.io/AlexSND/pen/zXxWxV
Upvotes: 0
Reputation: 494
In this plugin js you need change the files lightbox.js and the lightbox.css (or respectives .min)
First: In lightbox.js find:
<div class="lb-closeContainer"><a class="lb-close"></a></div>
and then cut and past inside
<div class="lb-outerContainer">
Now, in CSS you adjust the classes. Change all .lb-data .lb-close by .lb-outerContainer .lb-close and finally add style:
.lb-outerContainer .lb-close {
position:absolute;
right: -30px;
top: -30px;
}
Upvotes: 0
Reputation: 1
Solution from Lokesh Dhakar not quite right, tag with the lb-close class should be placed in the end of lb-nav class then the button will work correctly and display. Also do not forget to add .lb-nav tag to .lb-close, so that it would be like this: .lb-nav a.lb-close {...}
Upvotes: -1
Reputation: 5569
There is no API offered by the library to make this change so you will have to hack/monkeypatch it.
Modifying the html. The ideal way to do this would be to update the markup generated by lightbox.js and move the <a>
tag with the lb-close
class inside of <div class="lb-container">
as pictured below. To do this, you could modify lightbox.js. On line 102 you can see the markup that is generated: https://github.com/lokesh/lightbox2/blob/dev/dist/js/lightbox.js#L102
Positioning with CSS. Then you would need to apply some CSS for positioning the 'X' button:
position: absolute;
right: 16px;
top: 16px;
Oh and note that since the anchor tag with the lb-close
has been moved, the CSS selector that previously styled it has been updated. Now it is simply .lb-close
.
Upvotes: 0
Reputation: 1
.lb-data .lb-close {
display:block;
position:absolute;
right:50px;
top:5px;
/*float: right;*/
}
like that I resolved it
Upvotes: 0