When I resize my window to a smaller size, like that of a smartphone screen, the three inner divs (colored red, green, and blue - .left, .center, and .right) do not align in the center. Please refer to the screenshot attached for clarity. My goal is to ensure that all three divs are centered within the main .container div (pink) whenever the window size is reduced. Any suggestions would be greatly appreciated.
https://i.stack.imgur.com/43aYX.jpg
html,body {
width: 100%;
left: 0px;
top: 0px;
margin: 0px;
height: 100%;
}
.container {
width: auto;
left: 0px;
top: 0px;
float: none;
width: auto;
max-width: auto;
position: relative;
background-color: rgba(216, 86, 112, 0.5);
height: 100%;
margin-top: auto;
margin-right: 5%;
margin-left: 5%;
display: block;
right: 0px;
}
.top {
width: 100%;
left: 0px;
top: 0px;
background-color: rgba(204, 51, 0, 1);
height: 10%;
position: relative;
margin: 0px;
text-align: center;
}
.left {
float: left;
height: auto;
width: 331px;
background-color: rgba(255, 0, 0, 1);
margin-left: auto;
margin-right: auto;
position: relative;
left: auto;
top: 0px;
}
.center {
float: left;
height: auto;
width: 331px;
background-color: rgba(0, 255, 0, 1);
margin-left: 0px;
margin-right: auto;
position: relative;
left: 0px;
}
.right {
float: left;
height: auto;
width: 331px;
background-color: rgba(0, 0, 255, 1);
margin-left: 0px;
margin-right: auto;
position: relative;
left: 0px;
top: 0px;
}
<div class="container">
<div class="top"></div>
<div class="left">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vehicula quis dolor sed euismod. Fusce id tellus est. Nam eu rutrum urna. Donec mattis a libero faucibus euismod. Suspendisse iaculis placerat sapien in ultrices.
</div>
<div class="center">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vehicula quis dolor sed euismod. Fusce id tellus est. Nam eu rutrum urna. Donec mattis a libero faucibus euismod. Suspendisse iaculis placerat sapien in ultrices.
</div>
<div class="right">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vehicula quis dolor sed euismod. Fusce id tellus est. Nam eu rutrum urna. Donec mattis a libero faucibus euismod. Suspendisse iaculis placerat sapien in ultrices.
</div>
</div>