Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create hexagon design dynamically using css and js [duplicate]

This is not duplicate of any please help me

I got some trick here http://jsfiddle.net/kizu/bhGn4/

I want to create it dynamically with CSS , so how to do that?

whenever any new entry added to design that adjust automatically.

I have tried hard to search and i got some help for circle shape at here

How to create circles around a circle with css, javascript?

same something I want with hexagon

enter image description here

like image 537
anytime Avatar asked Sep 25 '13 12:09

anytime


1 Answers

Go through this demo which I've created:

.hexagon {
  width: 100px;
  height: 55px;
  background: red;
  position: absolute;
}
.hexagon:before {
  content: "";
  position: absolute;
  top: -25px;
  left: 0;
  width: 0;
  height: 0;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  border-bottom: 25px solid red;
}
.hexagon:after {
  content: "";
  position: absolute;
  bottom: -25px;
  left: 0;
  width: 0;
  height: 0;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  border-top: 25px solid red;
}
.hex1 {
  top: 20px;
  left: 0px;
}
.hex2 {
  top: 20px;
  left: 110px;
}
.hex3 {
  top: 20px;
  left: 220px;
}
.hex4 {
  top: 110px;
  left: 55px;
}
.hex5 {
  top: 110px;
  left: 165px;
}
.hex6 {
  top: 110px;
  left: 275px;
}
<div style="position:absolute; top:30px">
  <div class="hexagon hex1"></div>
  <div class="hexagon hex2"></div>
  <div class="hexagon hex3"></div>
  <div class="hexagon hex4"></div>
  <div class="hexagon hex5"></div>
  <div class="hexagon hex6"></div>
</div>
like image 144
Hari Avatar answered Sep 25 '22 23:09

Hari