I want to fit span background-color to text size in parent container. The problem is the container already have css properties. I can make some change but this properties are parsed dynamicaly.
For now it's like this:
It need to be like this:
I already tried methods from How do I set the background color of targeted text only, using only CSS? but non of this works becouse of css properties from parent element
<div>
<span>
The Last Will and Testament of
Eric Jones dsamd kaldmlsakd msalkd maslk dmaslkd maskld msalkd amsdlk asmdlk asmdkl asmd klsam dlkask dasmd lksamd lkasmd lskadm lksad mlsakd mlsak
</span>
</div>
div{
top: 10px;
left: 10px;
width: 450px;
height: 180px;
font-family: arial;
font-size: 12px;
font-weight: 400;
font-style: normal;
text-decoration: none;
color: #000000;
text-transform: none;
border-color: #FFF000;
border-width: 1px;
border-style: dotted;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAA1BMVEX/AAAZ4gk3AAAASElEQVR4nO3BgQAAAADDoPlTX+AIVQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwDcaiAAFXD1ujAAAAAElFTkSuQmCC);
background-color: #ff0000;
justify-content: flex-start;
text-align: left;
align-items: center;
overflow: hidden;
position: absolute;
display: flex;
}
span{
background-color:blue;
display: block;
}
https://jsfiddle.net/Shinen/jom70fv6/34/
Maybe there is a way to make changes in span style to make it work?
Best wishes :)
SOLUTION
The soultion what i found is to put span into another container. Maybe someone have better idea? https://jsfiddle.net/Shinen/jom70fv6/37/