Z
Z
zlodiak2020-04-09 19:29:12
reCAPTCHA
zlodiak, 2020-04-09 19:29:12

How to stretch a group of blocks in width?

There is a block that contains three indoor blocks. For one of the inner blocks, I set the width a little larger than the rest.

LIVE DEMO

But the width of other indoor units remains the same. And I would like the width of all internal blocks to always be the same. That is, it filled the parent block completely. How to do it?

It is important to keep the presence of a horizontal scroll.

<div class="wrap">
  <div class="table">
    <div class="level level1">1</div>
    <div class="level level2">2</div>
    <div class="level level3">3</div>
  </div>
</div>


.wrap {
  margin: 0 auto;
  width: 400px;
  background: red;
}

.table {
  width: 100%;
  background: yellow;
  overflow-x: auto;

}

.level {
  background: lime;
  height: 40px;
  
  
}

  .level1 {
    background: magenta;
    width: 600px;
  }
  
  .level2 {
    background: green;
    width: 100%;
  }
  
  .level3 {
    background: blue;
    width: 100%;
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
inzeppelin, 2020-04-09
@zlodiak

It's hard to understand, but maybe you want something like this:

.wrap {
  margin: 0 auto;
  width: 400px;
  background: red;
  overflow-x: auto; // скролл уводим наверх
}

.table {
  background: yellow;
  display: inline-block; // блок шириной по содержимому
}

the rest unchanged
LIVE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question