<div class="container">
<div class="block element-1">100% - 50px</div>
<div class="block element-2">50px</div>
</div>
/*Setup Environment */
/*
boring stuff
*/
html {
box-sizing: border-box;
}
:root {
background-color: #373150;
font-size: 16px;
font-weight: 400;
text-rendering: geometricPrecision;
line-height: 1.4;
text-decoration-skip: ink;
font-family: -apple-system-headline, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
*, *:before, *:after {
box-sizing: inherit;
}
body {
margin:0;
padding:0;
}
.block {
display:inline-block;
background-color:#EF6174;
color:white;
font-size:0.8em;
text-align:center;
line-height:4em;
}
/*
Calc Demo 100% Fluid Width.
--
The Width of element 1 is determined by the size of the container width, minus the spacing and width of element 2.
Useful in a responsive, re-usable widget scenario. Since the overall size is controlled by 1 container width, but adaptable to fit in any size.
*/
.container {
display:block;
max-width:900px;
margin:0 auto 20px auto;
}
/* calc( 100% width - width of element 2)*/
.element-1 {
float:left;
height:50px;
width: calc( 100% - 50px );
}
/*Notice how calc can also account for the additioanl spacing appled via margin-left here. */
.element-2 {
float:left;
width: 40px;
height:50px;
margin-left:10px;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.