Position items inside flex container using only css

I am working on a CSS file where I need to use flex to position the elements.

The elements should look like this:

======================================|--------|
            Header                    |        |    
======================================| edge-1 | 
     |                                |--------|
     |                                |        | 
Nav  |         Information            | edge-2 | 
     |                                |--------|
     |                                |        | 
     |                                | edge-3 |
======================================|        |
        Footer                        |        | 
=======================================--------|        

Details about the element size are:

• The left side container (Header, Nav, Information, Footer) needs 4/5 of the parent's width.
• The right side container (edges 1,2,3) needs 1/5 of the parent's width.

• The Nav needs 1/4 of the parent's width. 
• The Information needs 3/4 of the parent's width.
• The Header needs 1/5 of the parent's height.
• The Footer needs 1/5 of the parent's height.

I have below index.html file which is read only file:

body {
  margin: 0;
  font-family: Arial, sans-serif;
}

.holder {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.elements {
  display: flex;
  flex: 1;
}

.left-portion {
  display: flex;
  flex-direction: column;
  flex: 4;
}

.right-portion {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.header {
  flex: 1;
  background-color: #f1f1f1;
}

.footer {
  flex: 1;
  background-color: #f1f1f1;
}

.content {
  display: flex;
  flex: 3;
}

.nav {
  flex: 1;
  background-color: #e1e1e1;
}

.information {
  flex: 3;
  background-color: #d1d1d1;
}

.item {
  border: 1px solid #ccc;
  margin: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.edge-1,
.edge-2,
.edge-3 {
  flex: 1;
  background-color: #c1c1c1;
}
<div>
  <div class="Holder">
    <div class="elements">
      <div class="left-portion">
        <div class="item header" data-title="header"></div>
        <div class="content">
          <div class="item nav" data-title="nav"></div>
          <div class="item information" data-title="information"></div>
        </div>
        <div class="item footer" data-title="footer"></div>
      </div>

      <div class="right-portion">
        <div class="item edge-1" data-title="edge-1"></div>
        <div class="item edge-2" data-title="edge-2"></div>
        <div class="item edge-3" data-title="edge-3"></div>
      </div>
    </div>
    <div class="template">
      <div class="item item-1" data-title="header"></div>
      <div class="item item-2" data-title="nav"></div>
      <div class="item item-3" data-title="information"></div>
      <div class="item item-4" data-title="footer"></div>
      <div class="item item-5" data-title="edge-1"></div>
      <div class="item item-6" data-title="edge-2"></div>
      <div class="item item-7" data-title="edge-3"></div>
    </div>
  </div>
</div>

With this css I am able to align elements which are under div portion “Holder -> elements”

Now I was told to modify this css based on test case script:

  it.each([
    'header', 'nav', 'information', 'footer', 'edge-1', 'edge-2', 'edge-3'
  ])('verify element %s ', async (element) => {
    const elements = await driver.findElement(By.css(`.elements [data-title="${element}"]`))
    const template = await driver.findElement(By.css(`.template [data-title="${element}"]`))

    const eRect = await elements.getRect()
    const tRect = await template.getRect()

    const deviation = 2
    expect(Math.abs(tRect.y - eRect.y)).toBeLessThanOrEqual(deviation)
    expect(Math.abs(tRect.x - eRect.x)).toBeLessThanOrEqual(deviation)

    expect(Math.abs(tRect.width - eRect.width)).toBeLessThanOrEqual(deviation)
    expect(Math.abs(tRect.height - eRect.height)).toBeLessThanOrEqual(deviation)
  })

Here the test script needs the items which are under Div class “template” to be inside the flex container holder.

I am stuck here on how to modify the css without touching HTML and test scripts.

7

For 2D layouts I prefer grid over flex.

.elements {
  display: grid;
  grid-template-columns: 1fr 3fr 1fr;
  grid-template-rows: 1fr 3fr 1fr;
  grid-template-areas: "header header sidebar" "nav info sidebar" "footer footer sidebar";
  gap: 2px;
  color: white;
}

.elements .left-portion, .elements .left-portion .content {
  display: contents;
}

.elements .header, .elements .nav, .elements .information, .elements .footer, .elements .right-portion {
  padding: 0.5em;
}

.elements .header {
  grid-area: header;
  background: dodgerblue;
}

.elements .nav {
  grid-area: nav;
  background: orange;
}

.elements .information {
  grid-area: info;
  background: blue;
}

.elements .footer {
  grid-area: footer;
  background: pink;
}

.elements .right-portion {
  grid-area: sidebar;
  background: green;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}
<div class="elements">
  <div class="left-portion">
    <div class="item header" data-title="header">header</div>
    <div class="content">
      <div class="item nav" data-title="nav">nav</div>
      <div class="item information" data-title="information">information</div>
    </div>
    <div class="item footer" data-title="footer">footer</div>
  </div>
  <div class="right-portion">
    <div class="item edge-1" data-title="edge-1">edge-1</div>
    <div class="item edge-2" data-title="edge-2">edge-2</div>
    <div class="item edge-3" data-title="edge-3">edge-3</div>
  </div>
</div>

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật