I have the carousel slider in Bootstrap and this is my carousel-caption.
<div class="carousel-caption">
<p class="mx-auto text-center">Sed eros orci, faucibus at ex mollis, luctus fringilla erat. Etiam vel nibh velit. Nulla mattis tortor vel orci elementum consectetur sit amet ultrices metus. Donec ac arcu sed justo maximus fringilla vel eu nulla. In vel vestibulum metus. Maecenas et nisl eget ante mattis fermentum. </p>
</div>
I want text has a background cover width 100% but the size of text be 40% and when when the size in p change the height of carousel-caption change proportionally, with the text centered vertically and horizontally. I have the next CSS:
.carousel-caption {
position: absolute;
top: 50%;
left:0;
right:0;
bottom: 0;
transform: translateY(-32%);
background: #000;
text-align: center;
padding-top: 5%;
padding-bottom: 5%;
max-height: 30vh;
}
p {
width: 40%;
}
Thanks in advance for your help.