I need to create a markup that has the following structure:
<div id="container">
<div id="left">
This is the main text.
</div>
<div id="center">
Hello!
</div>
<div id="right">
some content
</div>
</div>
The block-level #container
element needs to be absolutely positioned and centered horizontally within the browser window by its width. The height should not affect the positioning:
#container {
display: block;
width: 95vw;
background-color: white;
position: absolute;
top: 75px;
}
The #center
element should have flexible dimensions without predefined width or height. It will expand based on content while maintaining a minimum width and padding of 20 pixels:
#center {
display: block;
background-color: green;
padding-left: 10px;
padding-right: 10px;
}
The #left
element should fill any remaining space in the #container
and include an ellipsis for overflow:
#left {
display: block;
background-color: red;
padding-left: 10px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
The #right
element should also occupy any leftover space in the container, serving as an independent block-level element that can hold various content:
#right {
display: block;
background-color: blue;
}
The final look should resemble the diagram provided, where the elements are perfectly centered and spaced accordingly. To achieve this specific layout, the solution cannot rely on defining fixed dimensions for each element and applying absolute positioning separately.