I want to create the below given box by using CSS.
I searched a lot and read very good articles like https://css-tricks.com/examples/ShapesOfCSS/ but I got stuck in one issue - the purple border cutting edges. I tried octagon shape but that is not working for this case.
I almost achieved this. Here is my snippet:
.box-outer {
width: 300px;
height: 120px;
padding: 15px 30px;
background: rgba(237, 236, 236, 0.72);
border: 3px solid rgb(89, 67, 128);
position: relative;
border-right: 20px solid rgb(89, 67, 128);
}
.box-outer:before {
content: "";
position: absolute;
top: -3px;
left: -4px;
border-bottom: 29px solid rgb(255, 252, 252);
border-right: 29px solid #594380;
border-top: 28px solid #FFF;
height: 66%;
width: 0;
}
.box-outer:after {
content: "";
position: absolute;
top: -3px;
right: -13%;
border-top: 29px solid white;
border-left: 29px solid #594380;
border-bottom: 28px solid #FFF;
width: 0;
height: 66%;
}
.box-outer .right-text {
position: absolute;
right: -22%;
color: white;
font-size: 20px;
top: 40%;
z-index: 10;
transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
}
<div class="box-outer">
<span class="right-text">
LEGISLATIVE
</span>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
<!--box outer-->
Current work screenshot
please check out this solution finally i made it
I add box-inner div to make this possible.
check out fiddle
Here is an alternate method using CSS3 transforms to achieve the octagon shape and also have transparency inside it. While using this method, the background need not be a solid color. It can be a image or a gradient.
The shape essentially consists of the following:
* - different colors are used only for illustrating how the shape is formed.
Other methods to get Octagon Shapes:
Here is a svg solution.
Unfortunately it uses some hard coded numbers for size.
I find the vertical text much easier to do in svg since you can simply rotate it by 90deg and it works.
The main element is two polygons. Considered using an gradient for elements background, but choose this because its easier to understand what's going on with the shapes.
The text element is done with a div and setting it absolute with fixed sizes. I find that this could be done better but could not think of a better solution at the top of my head.