I want to achieve something like
here the left div should take the remaining width and the right div (probably floated) div to take content width.
is it possible to achieve this without using flex
?
I want to achieve something like
here the left div should take the remaining width and the right div (probably floated) div to take content width.
is it possible to achieve this without using flex
?
You can use a CSS grid here, which offers a new type of unit fr
(which is one fraction of the remaining width).
article {
border: 2px solid green;
display: grid;
column-gap: 5px;
grid-template-columns: 1fr auto;
padding: 2px;
}
aside {
border: 2px solid blue;
}
main {
border: 2px solid red;
}
<article>
<aside>Takes remaining width.</aside>
<main>Takes content width.</main>
</article>
<article>
<aside>Takes remaining width.</aside>
<main>Takes content width. If this gets wider, aside gets narrower.</main>
</article>