I am facing an issue with two div
s placed side by side.
They appear fine when the page is viewed in full-screen mode.
However, upon resizing the window, the right div
overlaps the left one and causes a messy layout.
.
-I want to prevent these boxes from stacking on top of each other when the window size changes.
I attempted to use max-width;
and min-width;
properties but was unsuccessful in fixing the problem.
.
-I also tried adjusting the font sizes to be smaller or larger based on the window size using values like font-size: 70%;
, but it did not work as intended.
CSS:
.leftbox {
top: 15%;
position: absolute;
color: white;
padding: 10px;
font-size: 2em;
max-width: 700px;
overflow: hidden;
background: rgba(121, 183, 0, 0.9);
box-shadow: 0 4px 10px 4px rgba(43, 141, 6, 0.85);
}
#rightbox {
top: 15%;
right: 5%;
position: absolute;
background: rgba(121, 183, 0, 0.9);
padding: 40px;
max-width: 500px;
border-radius: 4px;
box-shadow: 0 4px 10px 4px rgba(43, 141, 6, 0.85);
font-size: 2em;
color: white;
}
HTML
<div class="leftbox">
[Lorem Ipsum text for leftbox goes here]
</div>
<div id="rightbox">
[Lorem Ipsum text for rightbox goes here]
</div>
JSFiddle: https://jsfiddle.net/p6mttf9q/