This Grail layout, I want the .right element to be displayed to the left of the .left. why didn't it work?

https://codepen.io/niusz/pen/.

When using negative margin, I found that if I didn"t use negative margin on .left to get it up first, I wouldn"t go up no matter how much,. Right I had for .right negative margin. Why is that?

Mar.10,2021

HTML Code:

<div class="ct">
  <div class="left">left</div>
  <div class="right">right</div>
   <div class="main">main</div>
</div>

CSS Code:

.left,
.right {
  width: 100px;
  height: 100px;
}
.left {
  background: blue;
  float: left;
}
.right {
  background: green;
  float: right;
}
.main {
  background: red;
  height: 100px;
  margin: 0 100px;
}


because width:100% is set for .main, so squeeze the following .left and .right to the next line.
you set .main to width:calc (100%-100px); and width:calc (100%-99px); compare it.


.main {
  background: red;
  float: left;
  height: 100px;
  width: 100%;
/*   margin-left: 50px ; */
  margin-right: 
 
}

you are squeezed out because you set main to width:100;. If you want to keep them on one line and keep them 100%, you can set them in main

.
margin-left:-200px;

remove right at the same time

margin-left: -510px;
Menu