Unimportant CSS question for anyone who wants to p...
# cfml-general
d
Unimportant CSS question for anyone who wants to play. I have a page with somewhat dynamic panels. CSS for a panel includes float: left; width 48%; . Net effect is two columns, with each row starting below the bottom of the taller of the two panels above. Is there a simple css-only way to have each panel "tuck up", to start just below the panel immediately above it, instead of below the taller of the two panels above it? I'm thinking no, but thought I'd ask.
j
Not easily without JavaScript to equalize the height of adjacent columns, With CSS flex
align-items
it is very easy to do: https://css-tricks.com/snippets/css/a-guide-to-flexbox/#aa-align-items
m
not exactly the same, but would fill the space, and sequentially, doing column 1 first then column 2. no need for floats or width.
Copy code
<div class="holdsPanels">
    <div class="panel" style="height: 80px; border: 1px solid grey;">
        <div>
            <strong>1</strong> style="height: 80"
        </div>
    </div>
    <div class="panel" style="height: 40px; border: 1px solid red;">
        <div>
            <strong>2</strong> style="height: 40"
        </div>
    </div>
    <div class="panel" style="height: 50px; border: 1px solid orange;">
        <div>
            <strong>3</strong> style="height: 50"
        </div>
    </div>
    <div class="panel" style="height: 60px; border: 1px solid blue;">
        <div>
            <strong>4</strong> style="height: 60"
        </div>
    </div>
    <div class="panel" style="height: 70px; border: 1px solid green;">
        <div>
            <strong>5</strong> style="height: 70"
        </div>
    </div>
  </div>

  <style>
div.panel {
  margin-bottom: 10px;
  break-inside: avoid;
}

div.holdsPanels {
  column-count: 2;
  column-gap: 10px;
}
  </style>
d
Found this, looks very promising: https://mastery.games/post/tile-layouts/ I wasn't able to get it to behave like I wanted in the time I had, so going to punt for now. Thanks for the ideas.
b
@Dave Merrill, that is the kind of question you might want to ask ChatGPT. As a test, I asked it the following question, and it had plenty to say:
"A CSS question. I have a page with somewhat dynamic panels.
CSS for a panel includes float: left; width 48%; .
Net effect is two columns, with each row starting below the bottom of the taller of the two panels above.
Is there a simple css-only way to have each panel "tuck up", to start just below the panel immediately above it, instead of below the taller of the two panels above it?
I'm thinking no, but thought I'd ask ChatGPT."
👍 1
d
Thank you! Besides the actual answer it gave, this is literally the first time I've seen ChatGPT give a non-trivial, non-hallucinatory, and actually useful response. Haven't tried it yet, might turn out to be bs, but it passed my first-level sniff test, which is cool.