Skip to content

Instantly share code, notes, and snippets.

@fredmaggiowski
Created September 7, 2016 15:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredmaggiowski/a62be624aeec0fec161df40084610e1a to your computer and use it in GitHub Desktop.
Save fredmaggiowski/a62be624aeec0fec161df40084610e1a to your computer and use it in GitHub Desktop.
Octagon HTML/CSS shape
.my-container {
margin-top: 50px;
padding: 20px;
font-size: 18px;
}
.octagon {
display: inline-block;
width: 40px !important;
height: 20px;
background: #3498db;
position: relative;
-webkit-box-shadow: 6px 6px 19px 2px rgba(0, 0, 0, 0.62);
-moz-box-shadow: 6px 6px 19px 2px rgba(0, 0, 0, 0.62);
box-shadow: 6px 6px 19px 2px rgba(0, 0, 0, 0.62);
text-shadow: black 0.1em 0.1em 0.2em
}
.octagon:before {
content: "";
position: absolute;
top: -10px;
left: 0px;
width: 20px;
height: 0px;
border-bottom: 10px solid;
border-bottom-color: inherit;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
z-index: 1;
}
.octagon:after {
content: "";
position: absolute;
bottom: -10px;
right: 0px;
width: 20px;
height: 0px;
border-top: 10px solid;
border-top-color: inherit;
border-right: 10px solid transparent;
border-left: 10px solid transparent;
z-index: 1;
}
.octagon {
color: #ecf0f1;
font-family: helvetica;
font-size: 20px;
text-align: center;
font-weight: bold;
text-shadow: 1px 1px 7px rgba(0, 0, 0, 1);
z-index: 3;
}
.o-color.red {
background-color: #e74c3c;
border-top-color: #e74c3c;
border-bottom-color: #e74c3c;
}
.o-color.green {
background-color: #27ae60;
border-top-color: #27ae60;
border-bottom-color: #27ae60;
}
.o-color.blue {
background-color: #2980b9;
border-top-color: #2980b9;
border-bottom-color: #2980b9;
}
.o-color.purple {
background-color: #8e44ad;
border-top-color: #8e44ad;
border-bottom-color: #8e44ad;
}
<body>
<div class="my-container o-color red">
A: <span class="octagon o-color green">10</span>
</div>
<div class="my-container o-color purple">
B: <span class="octagon o-color blue"><span>100</span></span>
</div>
<div class="my-container">
C: <span class="octagon o-color red">1</span>
</div>
</body>
@Jitendra08
Copy link

Screenshot (45)
how to create this type of octagon shape .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment