0

So in my layout i'll have a main searchbar along with two buttons.

Just below there are various entries. Which one has a clickable Title to show it's contents and open/close buttons.

Here's a JSfiddle MVE (with only two entries.)

Since the titles are clickable i want them to occupy all the remaining space up to the floating buttons.

Current VS Desired behaviour

I've tried adding two options to .entry_title:

.entry_title {
   display: inline;
   width: 100%;
}

But this way the title will actually occupy a whole line (thus moving the buttons to the next one). I've also tried all the other display options.

I've tried solutions to other answers (link, link) but couldn't make them work in my setup.

Henri Augusto
  • 309
  • 3
  • 14

3 Answers3

1

Skip the floats and use flex box. Just add display:flex; to .entry-bar and flex-grow:1; to .entry-title;

.entry_bar {
  display:flex;
}

.entry_title {
    background-color: green;
    user-select: none;
    flex-grow:1;
}
j08691
  • 204,283
  • 31
  • 260
  • 272
  • 1
    Both this and @jpmarks answers are good. I'm accepting this one because in this scenario i think flex boxes seem simpler. But the other grid solution given is more scalable. – Henri Augusto Jul 13 '20 at 23:07
1

Try changing your .entry_bar css to this:

.entry_bar {
  display: grid;
  grid-template-columns: 1fr max-content max-content;
}

I hardly recommend looking into CSS grid. Here is a great guide by css-tricks CSS -Grid Guide

Jan-Philipp Marks
  • 1,419
  • 8
  • 13
0

You can use flex-box

.entry_bar {
  display:flex;
}

.entry_title {
    flex: 1;
}
Marik Ishtar
  • 2,899
  • 1
  • 13
  • 27