Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS DIV Layout over Grid

Tags:

html

css

enter image description here

Is it possible to get this Layout using div's

like image 369
George Moik Avatar asked Dec 06 '25 06:12

George Moik


2 Answers

You could do this with floats and negative margin-top on .e. With masonry you don't need margin-top DEMO

* {
  box-sizing: border-box;
}
.content {
  width: 200px;
  height: 200px;
  border: 1px solid black;
}
.item {
  border: 1px solid black;
  float: left;
  display: flex;
  align-items: center;
  justify-content: center;
}
.a,
.d {
  width: 33.3333333%;
  height: 66.67%;
}
.b,
.e {
  width: 66.67%;
  height: 33.3333333%;
}
.e {
  margin-top: -33.3333333%;
}
.c {
  width: 33.3333333%;
  height: 33.3333333%;
}
<div class="content">
  <div class="a item">a</div>
  <div class="b item">b</div>
  <div class="c item">c</div>
  <div class="d item">d</div>
  <div class="e item">e</div>
</div>
like image 97
Nenad Vracar Avatar answered Dec 07 '25 22:12

Nenad Vracar


Yes it is possible.

I made a fast snippet for you. Using position: absolute.

* {
  padding: 0;
  margin: 0;
}

.container {
  width: 150px;
  height: 150px;
}

.a {
  position: absolute;
  height: 100px;
  width: 50px;
  background-color: #CCC;
}

.b {
  position: absolute;
  left: 50px;
  height: 50px;
  width: 100px;
  background-color: #C2C2C2;
}

.c {
  position: absolute;
  left: 50px;
  top: 50px;
  width: 50px;
  height: 50px;
  background-color: #EEE;
}

.d {
  position: absolute;
  left: 100px;
  top: 50px;
  height: 100px;
  width: 50px;
  background-color: #F0F0F0;
}

.e {
  position: absolute;
  left: 0px;
  top: 100px;
  width: 100px;
  height: 50px;
  background-color: #DDD;
}
<div class="container">

  <div class="a"></div>
  <div class="b"></div>
  <div class="c"></div>
  <div class="d"></div>
  <div class="e"></div>

</div>
like image 40
S.Visser Avatar answered Dec 07 '25 20:12

S.Visser