When pasting text into an image in this example, everything looks fine at first. However, as the browser width is reduced, the text starts slipping out of the picture.
To make matters worse, unsightly line breaks are also added.
Is there a way to prevent these two issues?
I'm looking for a solution that doesn't involve using scrollbars.
This thread discusses long text going outside the div
For reference, you can view an example here: https://jsfiddle.net/1228sbg7/3/
.image {
position: relative;
width: 33%;
height: auto;
}
h2 {
position: absolute;
top: 200px;
left: 0;
width: 100%;
}
h2 span {
color: white;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgb(0, 0, 0); /* fallback color */
background: rgba(0, 0, 0, 0.7);
padding: 10px;
}
h2 span.spacer {
padding:0 5px;
}
<div class="image">
<img src="https://www1.xup.in/exec/ximg.php?fid=21049048" alt="" />
<h2><span>Lorem ipsum dolor sit amet:<span class='spacer'></span><br /><span class='spacer'></span>consetetur sadipscing elitr</span></h2>
</div>