I need the red marker to be identical to the green marker in its width
and height
.
Note that the red marker displays on a blank space.
I want the RED MARKER to mark the paragraph which is on the right panel (panel-two).
I tried to make them width: 100%
height: 100%
so that it’ll get the attributes of its container – but that doesn’t help.
Thank you very much!
body {
overflow-x: hidden;
}
.drag-container {
display: flex;
min-height: 100vh;
overflow-x: hidden;
}
.panel-one {
position: relative;
width: 50%;
}
.panel-two {
position: relative;
flex: 1;
width: 50%;
}
.m-aquamarine {
background-color: aquamarine;
}
.m-red {
display: inline-block;
position: absolute;
left: 50px;
width: 100%;
height: 100%;
background-color: red;
opacity: 0.3;
}
<body>
<div class="drag-container">
<div class="panel-one">
<img src="https://i.sstatic.net/x80pyPiI.png" width="100%">
<p>
<span class="m-aquamarine">
Hey Gustaf! Azng sjczv zncsn djfandz czns!!
</span>
<span class="m-red"></span>
<span class="m-red"></span> Dzns kds fdskcznc eandz ncz!?!</p>
</div>
<div class="panel-two">
<div class="container">
<img src="https://i.sstatic.net/x80pyPiI.png" ; style="display: block; width: 100%;">
<p>Hello there! Erkdfs dms djc zc dnacjzz csjdasc!!</p>
</body>
3
Answers
I can’t think of a way which will exactly replicate the shape and work well when the text is split over several lines.
Here is an imperfect method which at least follows the shape of the text when it is over more than one line given here in the hope that it suggests a method which can be refined.
Just change the HTML so the text you want to highlight is in the
<span>
element and remove everything exceptbackground-color
from.m-red
CSS styles:I dont know if this is what you are looking for: i added a grid and displayed the pictures in the first row and the colored texts in row 3.
I am not sure if you want the hello text in between both elements so i added an additional row to the grid. if that is not desired just delete that row from the grid and adjust the aside grid-area to be placed in row 2
Important!!
Please note that the size of the columns in the grid and later in the color parts is just guessed based on the look. Please adjust it to match the real size of the Images!