I want the caption to have the same width as the image, 80% and be positioned centrally below the image. I’ve added additional css but the caption is left aligned to the lightbox window.
The additional CSS is currently as follows: #baguetteBox-overlay .full-image img {
max-height: 80% !important;
max-width: 80% !important;
}
#baguetteBox-overlay {
background-color: white !important;
}
#baguetteBox-overlay .full-image figcaption {
background-color: white !important;
color: black !important;
width: 80% !important;
margin-bottom: 35px;
text-align: center !important;
}
#baguetteBox-overlay .full-image figcaption {
background-color: white !important;
color: black !important;
width: 80% !important;
margin: 0 auto; /* This should centre the caption. */
margin-bottom: 35px;
text-align: center !important;
display: block;
}
Thanks Mike, I applied this but the caption is still not centred below the image. Looking at my css for the img I have applied a max height and max width of 80% so I tried adding those statements to the code you provided but that didn’t resolve.
#baguetteBox-overlay {
background-color: white !important;
}
#baguetteBox-overlay .full-image figcaption {
background-color: white !important;
color: black !important;
width: 80% !important;
margin: 0 auto; /* This should centre the caption. */
margin-bottom: 35px;
text-align: center !important;
display: block;
}
The Left, is relative to the parent. Moving the left edge of the caption to the middle.
The translateX, (relative to the element) moves the caption back halfway on the horizontal.
The result, a centered caption, that has a position absolute.