Make an Octagon in CSS

To make an octagon in CSS first we need to set up a div. We are going to give our div an id of octagon.

[code]<div id="octagon"></div>[/code]

Next we will insert the style for the octagon in our css stylesheet.

[code]<style>
#octagon {
width: 100px;
height: 100px;
background: gray;
position: relative;
}

Only cool people share!

#octagon:before {
content: "";
position: absolute;
top: 0;
left: 0;
border-bottom: 29px solid gray;
border-left: 29px solid #eee;
border-right: 29px solid #eee;
width: 42px;
height: 0;
}

#octagon:after {
content: "";
position: absolute;
bottom: 0;
left: 0;
border-top: 29px solid gray;
border-left: 29px solid #eee;
border-right: 29px solid #eee;
width: 42px;
height: 0;
}
</style>[/code]

To see more about creating octagons please see CSS tricks.

Make an Octagon in CSS was last modified: May 6th, 2015 by Maximus Mccullough
Summary
Make an Octagon in CSS
Article Name
Make an Octagon in CSS
Description
Make an Octagon in CSS copy and paste the codes.
Author
create-an-octagon-with-css

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.