0xkornel
0xkornel

Reputation: 134

Equally expand size of 2 divs

I am making template for html raport. I have problem with sizing this <div class="rule"></div>. I have two divs of this kind. I want then to be equally size, displayed next to each other and 2 of this div should take all avialible space of <div class="right_container"></div>. Final efect sholud be similar to this: enter image description here

I tried this but in smaller resolution screen second rule div goes to next line.

.rule{
  height:300px;
  width: 48%;
  background-color: rgb(55,55,55);
  border-radius:10px 10px 10px 10px;
  display: inline-block;
  margin-right: 15px;
  margin-top: 15px;
}

Is there any CSS Properties that can achive this?

body {
  background-color: rgb(45, 45, 45);
}

.container {
  width: 100%;
  height: 200px;
}

.left_container {
  height: 1500px;
  width: 500px;
  float: left;
  background-color: rgb(55, 55, 55);
  border-radius: 10px 10px 10px 10px;
  margin-top: 15px;
  margin-bottom: 15px;
  margin-right: 15px;
  margin-left: 15px;
}

.right_container {
  width: auto;
  overflow: hidden;
  background-color: rgb(255, 255, 255);
}

.right_container_plot {
  width: auto;
  height: 200px;
  background-color: rgb(55, 55, 55);
  overflow: hidden;
  margin-top: 15px;
  margin-left: 15px;
  border-radius: 10px 10px 10px 10px;
}

.rule {
  height: 300px;
  background-color: rgb(55, 55, 55);
  border-radius: 10px 10px 10px 10px;
  display: inline-block;
  margin-right: 15px;
  margin-top: 15px;
}

.label {
  background-color: rgb(70, 70, 70);
  font: 20pt "MS Shell Dlg 2";
  color: rgb(255, 255, 255);
  border-radius: 10px 10px 10px 10px;
  text-align: center;
  margin-top: 0px;
  margin-bottom: 0px;
  margin-right: 0px;
  margin-left: 0px;
}
<div class="container">
  <div class="left_container">
    <p class="label">Transactions</p>
  </div>

  <div class="right_container">
    <div class="rule">
      <p class="label">Buy rule</p>
    </div>
    <div class="rule">
      <p class="label">Sell rule</p>
    </div>
  </div>

  <div class="right_container_plot">
    <p class="label">Plot</p>
  </div>
</div>

Upvotes: 1

Views: 477

Answers (1)

Majid Feyzi
Majid Feyzi

Reputation: 104

Just add display: flex; to right_container class.

A flex container expands items to fill available free space or shrinks them to prevent overflow.

See below link for more info about CSS display property: https://www.w3schools.com/cssref/pr_class_display.asp

Upvotes: 4

Related Questions