For that you need to float: left;
the other element as well..
.right {
width: calc(100% - 40px);
background: blue;
float: left;
}
Also, am using calc()
here, to deduct the fixed width
sidebar which is 40px
from 100%
right bar.
As @Krimson commented that you want some space between the element as well, than use margin
.right {
width: calc(100% - 80px);
background: blue;
float: left;
margin-left: 40px;
}
Note: In the demo, am using overflow: hidden;
as a quick fix for clearing floats, but better use clear: both;
for that, for more information on clearing floats, you can read my answer here.
Inspected Elements