Using either Flexbox or CSS Grid, is it possible to sort my columns based on the contents of one of the columns?
Heres What I Want:
I have 2 columns, main and side .
|------------------------container--------------------------|
| |
||----------------------------------------|----------------||
|| main | side ||
||----------------------------------------|----------------||
| |
|-----------------------------------------------------------|
I want the side size to be automatically set based on its contents, and I want the main one to be twice as wide as the side, minimum. It can grow more, but not less.
As the container grows, main will grow at the same speed, and the side will remain automatic width.
|--------------------------container increases----------------------|
| |
||------------------------------------------------|----------------||
|| main increases | side ||
||------------------------------------------------|----------------||
| |
|-------------------------------------------------------------------|
3 , , main , . > . , .
|--------------------container----------------------|
| |
||--------------------------------|----------------||
|| main | side ||
||--------------------------------|----------------||
| |
|---------------------------------------------------|
, , , 100% :
|--------------------container--------------------|
| |
||-----------------------------------------------||
|| main ||
||-----------------------------------------------||
||-----------------------------------------------||
|| side ||
||-----------------------------------------------||
| |
|-------------------------------------------------|
Heres What Ive Tried:
Flexbox Grid, , .
.container-grid {
display: grid;
grid-template-columns: 1fr auto;
}
.container-flex {
display: flex;
flex-wrap: wrap;
}
.main { flex: 2; } .side { flex: 1; }
.main ( flex: 0 1 auto; } .side { flex: 0 0 auto; }
, Ive , - ( , ), - 3 . , , - , , -, .
.container-grid {
display: grid;
grid-template-columns: 1fr 15em;
}
@media screen and (max-width: 45em) {
.container-grid {
grid-template-columns: 1fr;
}
}