Make text box appear to the right of wrapper/clip-path - html

I have based my code out of this CSS Shapes Layout Pyramid from codepen: https://codepen.io/s-gupta/pen/jOMGbMX
I'm quite happy with the shape of my pyramid, but I also want a text box to appear to the right of each pyramid step when you hover over the element. I based my text box code on https://www.w3schools.com/css/css_tooltip.asp
However, as you see, the text box appears within the wrapper/pyramid, not outside of it. The text in the text box will be quite long, so it cannot be within the pyramid.
How can I make it go outside (and preferably to the right of the pyramid) ?
I'm quite new to CSS/HTML, but I'm trying to learn - Hope somebody out there can help me :)
body {
/*background: #333;
font-family: "SF UI Text", "Avenir", "Helvetica", arial, san-serif;
color: #888;*/
}
.wrapper {
margin: 5vh auto 0;
}
.pyramid {
float: left;
shape-outside:polygon(310px 0px, 130px 405px, 558px 405px);
padding-right:60px;
width: 700px;
height: 500px;
}
.zone {
padding:40px 0;
margin: 0 auto;
text-align:center;
color: black;
background-blend-mode:darken;
transition: 0.5s;
}
.zone:nth-child(1){
background:rgba(248,153,46); /* url("https://pixabay.com/static/uploads/photo/2016/01/05/13/34/laugenbrotchen-1122509_960_720.jpg") center / cover;*/
width: 20%;
clip-path:url("#part1");
clip-path:polygon(50% 0%,0%,100% 100%, 0% 100%);
/*-webkit-clip-path:polygon(50% 0%,100% 100%, 0% 100%);*/
}
.zone:nth-child(2){ background:rgba(248,153,46);
width: 40%;
clip-path:url("#part2");
clip-path:polygon(40% 0%,0%,60% 0, 100% 100%,0% 100%);
/*-webkit-clip-path:polygon(25% 0%,75% 0, 100% 100%,0% 100%);*/
}
.zone:nth-child(3){
width: 60%;
background:rgba(248,153,46);
clip-path:url("#part3");
clip-path:polygon(30% 0,0%, 70% 0, 100% 100%,0% 100%);
/*-webkit-clip-path:polygon(16.5% 0, 83% 0, 100% 100%,0% 100%);*/
}
.zone:nth-child(4){
background:rgba(248,153,46);
width: 80%;
clip-path:url("#part4");
clip-path:polygon(20% 0, 0%,80% 0, 100% 100%,0% 100%);
/*-webkit-clip-path:polygon(12.5% 0,87.5% 0, 100% 100%,0% 100%);*/
}
.zone:nth-child(5){
background:rgba(248,153,46);
width: 100%;
clip-path:url("#part5");
clip-path:polygon(10% 0, 0%,100% 0, 100% 100%,0% 100%);
/*-webkit-clip-path:polygon(12.5% 0,87.5% 0, 100% 100%,0% 100%);*/
}
/*.zone:hover {
background-color: rgba(118,113,113);
color: white;
}
*/
.zone .arrowtext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;
top: -5px;
left: 105%;
}
.zone .arrowtext::after {
content: " ";
position: relative;
top: 50%;
right: 100%; /* To the left of the tooltip */
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent black transparent transparent;
}
.zone:hover {
background-color: rgba(118,113,113);
color: white;
}
.zone:hover .arrowtext{
visibility: visible;
}
<div class="wrapper">
<div class="pyramid">
<div class="zone">0. zero
<span class="arrowtext">Tooltip text</span></div>
<div class="zone">1. One</div>
<div class="zone">2. Two</div>
<div class="zone">3. Three</div>
<div class="zone">4. Four</div>
</div>
<svg width="0" height="0">
<defs>
<clipPath id="part1" clipPathUnits= "objectBoundingBox">
<polygon points= "0.5 0, 1 1, 0 1"/>
</clipPath>
<clipPath id="part2" clipPathUnits= "objectBoundingBox">
<polygon points= "0.25 0,0.75 0, 1 1, 0 1"/>
</clipPath>
<clipPath id="part3" clipPathUnits= "objectBoundingBox">
<polygon points= "0.165 0,0.83 0, 1 1, 0 1"/>
</clipPath>
<clipPath id="part4" clipPathUnits= "objectBoundingBox">
<polygon points= "0.125 0,0.875 0, 1 1, 0 1"/>
</clipPath>
<clipPath id="part5" clipPathUnits= "objectBoundingBox">
<polygon points= "0.1 0,0.9 0, 1 1, 0 1"/>
</clipPath>
</defs>
</svg>
And further, how could I make the arrowtext go over several sentences? I figured I can make the width wider and reduce the clip path so that the triangle takes up less of the area. That solves the problem of making whole 1-2 lines visible, but what about getting text that goes over 2 lines? I've tried z-index for example, but does not work. In other words I'm looking for a way to make the text expand further than only the height of the hovered element or zone.

Here is a simplified version where I am reducing the size for the sake of the demo (feel free to update them).
The trick is to create triangle shapes using pseudo element on each "zone" element. By making them relative to "pyramid" they will overlap (creating the illusion of only one). Then by using clip-path:inset(0) on "zone" each one will show one portion on the triangle.
.pyramid {
width: 400px;
margin: auto;
z-index: 0;
position: relative; /* relative on "pyramid" and not "zone" */
}
/* build the triangle as pseudo element fo "zone" */
.zone:before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
background: rgba(248, 153, 46);
/* the pyramid shape */
clip-path: polygon(50% 0, 100% 100%, 0 100%);
transition: 0.5s;
}
.zone {
padding: 20px 0;
text-align: center;
cursor: pointer;
color: black;
clip-path: inset(0); /* clip the triangle to only the shape of each "zone"*/
}
/* using an extra div to correctly place the tooltip*/
.zone > div {
display:inline-block;
position:relative;
}
/* update color on hover */
.zone:hover {
color: white;
}
.zone:hover:before {
background: rgba(118, 113, 113);
}
/**/
.zone .arrowtext {
position: absolute;
visibility: hidden;
white-space:nowrap;
background-color: black;
color: #fff;
padding: 5px;
border-radius: 6px;
top: -5px;
left: 105%;
}
.zone:hover .arrowtext {
visibility: visible;
}
<div class="pyramid">
<div class="zone">
<div>0. zero<span class="arrowtext">Tooltip text</span></div>
</div>
<div class="zone">1. One</div>
<div class="zone">2. Two</div>
<div class="zone">3. Three</div>
<div class="zone">4. Four</div>
</div>

Related

transparent border (padding?) on circular image [duplicate]

I would like to make a transparent cut out half circle shape using only CSS3. The only requirement is that all the elements that form the shape must be black or transparent.
I cannot use a black rectangle with a white circle on top of it because the half circle has to be transparent and let the background show through.
Desired shape :
May be can do it with CSS :after pseudo property like this:
body {
background: green;
}
.rect {
height: 100px;
width: 100px;
background: rgba(0, 0, 0, 0.5);
position: relative;
margin-top: 100px;
margin-left: 100px;
}
.circle {
display: block;
width: 100px;
height: 50px;
top: -50px;
left: 0;
overflow: hidden;
position: absolute;
}
.circle:after {
content: '';
width: 100px;
height: 100px;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 100px;
background: rgba(0, 0, 0, 0);
position: absolute;
top: -100px;
left: -40px;
border: 40px solid rgba(0, 0, 0, 0.5);
}
<div class="rect"> <span class="circle"></span></div>
View on JSFiddle
You can use box-shadows to make the transparent cut out circle :
body {
background: url(http://i.imgur.com/qi5FGET.jpg) no-repeat;
background-size: cover;
}
div {
display: inline-block;
width: 300px; height: 300px;
position: relative;
overflow: hidden;
}
div:before {
content: '';
position: absolute;
bottom: 50%;
width: 100%; height: 100%;
border-radius: 100%;
box-shadow: 0px 300px 0px 300px #000;
}
.transparent {
opacity: 0.5;
}
<div></div>
<div class="transparent"></div>
This can be responsive with percentage lengths:
body {
background: url(http://lorempixel.com/output/people-q-c-640-480-1.jpg) no-repeat;
background-size: cover;
}
div {
width: 40%; height: 300px;
position: relative;
overflow: hidden;
}
div:before {
content: '';
position: absolute;
bottom: 50%;
width: 100%; height: 100%;
border-radius: 100%;
box-shadow: 0px 300px 0px 300px #000;
}
.transparent {
opacity: 0.5;
}
<div class="transparent"></div>
Using SVG:
Here is an alternate solution using SVG (though you haven't tagged it). Advantages of using SVG are:
It has better browser support when compared to radial-gradients.
SVG can support images inside the shape unlike the box-shadow approach.
While SVG is not supported by <= IE8 whereas box-shadow is, fallbacks can be provided.
svg {
height: 150px;
width: 150px;
}
polygon {
fill: black;
}
/* Just for demo */
body {
background-image: radial-gradient(circle, #3F9CBA 0%, #153346 100%);
}
<!-- Sample 1 - Using Clip Path -->
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<defs>
<clipPath id='clipper'>
<path d='M0,0 a50,50 0 1,0 100,0 l 0,100 -100,0' />
</clipPath>
</defs>
<polygon points='0,0 100,0 100,100 0,100' clip-path='url(#clipper)' />
</svg>
<!-- Sample 2 - Using Path -->
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<pattern id='bg' width='100' height='100' patternUnits='userSpaceOnUse'>
<image xlink:href='http://lorempixel.com/100/100/nature/1' height='100' width='100' />
</pattern>
<path d='M0,0 a50,50 0 1,0 100,0 l 0,100 -100,0 0,-100' fill='url(#bg)' />
</svg>
Using CSS:
CSS also has clip-path specifications and we can try something like in the below snippet.
.shape {
position: relative;
width: 100px;
height: 100px;
background-color: purple;
}
.shape:after {
position: absolute;
content: '';
top: 0px;
left: 0px;
height: 100%;
width: 100%;
background: white;
-webkit-clip-path: ellipse(50% 20% at 50% 0%);
clip-path: ellipse(50% 20% at 50% 5%);
}
.shape.image{
background: url(http://lorempixel.com/100/100);
}
#shape-2 {
width: 100px;
height: 100px;
background-color: purple;
-webkit-clip-path: ellipse(50% 20% at 50% 20%);
clip-path: ellipse(50% 20% at 50% 20%);
}
/* Just for demo */
.shape{
float: left;
margin: 20px;
}
#shape-2 {
margin: 150px 20px 0px;
}
<div class="shape"></div>
<div class="shape image"></div>
<br/>
<div id="shape-2"></div>
But unlike SVG clip-path, the pure CSS version (that is, without using an inline or external SVG) doesn't seem to be able to support a path. It only supports shapes and so in this case, if you use the clip-path on the parent directly it would just produce an ellipse (like shown in the snippet). To overcome this, we would have to put the clip-path on a child (or a pseudo element) and this would mean that the clipped area would not be transparent.
Using Canvas:
The same can be done using Canvas also. Canvas commands are pretty similar to SVG and their advantages are also pretty similar. However, Canvas are raster based and hence doesn't scale as well as SVG does.
window.onload = function() {
/* Canvas example with path */
var canvas = document.getElementById('canvas');
if (canvas.getContext) {
var ctx = canvas.getContext('2d');
var img = new Image();
img.src = 'http://lorempixel.com/150/300';
ctx.beginPath();
ctx.moveTo(110, 0);
ctx.arc(60, 0, 50, 0, 3.14, false);
ctx.lineTo(10, 145);
ctx.lineTo(110, 145);
ctx.closePath();
ctx.fill();
/* Use below for using image as a fill */
/*img.onload = function(){
var ptrn = ctx.createPattern(img,'no-repeat');
ctx.fillStyle = ptrn;
ctx.fill();
}*/
}
/* Canvas example with clip path */
var canvasClip = document.getElementById('canvas-clip');
if (canvasClip.getContext) {
var ctxClip = canvasClip.getContext('2d');
ctxClip.beginPath();
ctxClip.moveTo(10, 145);
ctxClip.lineTo(10, 0);
ctxClip.arc(60, 0, 50, 0, Math.PI * 2, true);
ctxClip.lineTo(110, 145);
ctxClip.lineTo(10, 145);
ctxClip.clip();
ctxClip.fillStyle = 'tomato';
ctxClip.fill();
}
}
canvas {
height: 150px;
width: 300px;
}
/* Just for demo */
body {
background-image: radial-gradient(circle, #3F9CBA 0%, #153346 100%);
}
<canvas id='canvas'></canvas>
<canvas id='canvas-clip'></canvas>
Using Masks:
This shape can be created by using CSS (or) SVG masks also. CSS masks have very poor support and work currently only in Webkit powered browsers but SVG masks have much better support and should work in IE9+.
/* CSS Mask */
.shape {
width: 150px;
height: 150px;
background-color: black;
-webkit-mask-image: radial-gradient(circle closest-corner at 50% 0%, transparent 98%, white 99%);
mask-image: radial-gradient(circle closest-corner at 50% 0%, transparent 98%, white 99%);
}
/* End of CSS Mask */
svg {
height: 150px;
width: 150px;
}
polygon#shape {
fill: black;
mask: url(#masker);
}
/* Just for demo */
body {
background-image: radial-gradient(circle, #3F9CBA 0%, #153346 100%);
}
<!-- CSS Mask -->
<div class='shape'></div>
<!-- SVG Mask -->
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<defs>
<mask id='masker' x='0' y='0' width='100' height='100'>
<polygon points='0,0 100,0 100,100 0,100' fill='#fff' />
<circle r='50' cx='50' cy='0' fill='#000' />
</mask>
</defs>
<polygon points='0,0 100,0 100,100 0,100' id='shape' />
</svg>
You can do it really easily with a radial gradient.
DEMO
Result:
HTML:
<div class='shape'></div>
Relevant CSS:
.shape {
margin: 0 auto;
width: 10em; height: 16em;
/* WebKit browsers, old syntax */
background: -webkit-radial-gradient(50% 0, circle, transparent 30%, black 30%);
/* IE10, current versions of Firefox and Opera */
background: radial-gradient(circle at 50% 0, transparent 30%, black 30%);
}
See http://caniuse.com/#feat=css-gradients for detailed info on compatibility.
Try this.
body{
background-color:#333;
passing:0px;
height:0px;
}
#app{
background:#333 url('https://source.unsplash.com/random') no-repeat;
background-size:cover;
width:360px;
height:560px;
position:relative;
overflow:hidden;
}
.app-bar{
width:100%;
height:50px;
position:absolute;
bottom:0px;
left:0;
}
.app-bar .bar{
line-height:50px;
position:relative;
width:100%;
height:50px;
background-image: radial-gradient(circle 35px at 315px 0, transparent 700px, #f44336 50px);
}
.app-bar .bar i{
color:#FFF;
display:block;
line-height:50px;
float:left;
width:50px;
text-align:center;
cursor:pointer;
margin-top:0px;
}
.app-bar .bar i:hover{
background-color:rgba(0,0,0,.1);
}
.app-bar .bar button{
padding:0px;
box-sizing:border;
text-align:center;
margin:0px;
bordeR:0px;
outline:0px;
width:60px;
height:60px;
line-height:60px;
cursor:pointer;
color:#FFFFFF;
display:block;
border-radius:50%;
position:absolute;
top:-30px;
left:100%;
margin-left:-75px;
background-color:#f44336;
transition: all .2s ease;
}
.app-bar .bar button span{
line-height:60px;
font-size:30px;
}
.app-bar .bar button:hover{
transform:rotate(45deg);
transition: all .2s ease;
}
<div id="app">
<div class="app-bar">
<div class="bar">
<i class="material-icons">menu</i>
<i class="material-icons">search</i>
<button class="button">
<span class="material-icons">add</span>
</button>
</div>
</div>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/material-design-icons/3.0.1/iconfont/material-icons.min.css" >
Kyle Sevenokas did some good work. And I built off of that. Checkout the http://jsfiddle.net/FcaVX/1/
I basically collapsed the white div for the circle and gave it white borders. The OP question talked about the colors elements that make up the shape; nothing about its borders right?
I needed rounded corners only on the bottom of a responsive image. I started from #sandeep fiddle and improved it for my needs:
.rect
{
height: 85vh;
position: relative;
background-color: red;
width: 60vw;
}
.circle-helper{
display: block;
width: 100%;
padding-bottom: 50%;
bottom: 0;
left: 0;
overflow: hidden;
position: absolute;
background-color: transparent;
}
.circle{
display: block;
width: 100%;
padding-bottom: 100%;
// height: 500px;
bottom: 0;
left: 0;
overflow: hidden;
position: absolute;
background-color: transparent;
}
.circle:after{
box-sizing: content-box;
content: '';
width: 100%;
height: 100%;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
background: rgba(0,0,0,0);
position: absolute;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
border: 300px solid blue;
}
top: 50%
left: 50%
border: 300px solid blue
https://jsfiddle.net/mop00j22/
Right now, the only way I can think of would be to use a lot of 1-pixel wide black divs next to eachother with varying height. It's technically possible this way but should be deeply frowned upon. Also; you won't have anti-aliassing unless you want to go through the trouble of adding 1x1 pixel divs and do the anti-aliassing manually.
It might be more helpful if you gave an example of how you wanted to use this. Why does it need to be black/transparent only? As stated by omarello, the best solution on most circumstances is probably a simple GIF or PNG image with transparency.

How to add multiple layers of overlays with transparency to an image using CSS

How can I push down the triangle and include the content on top of the white circles? I'm trying to find a solution for creating a hero section that contains a background image with the three overlay shapes included as part of the image. On top of the overlays will be an h1, p and btn. I included a screenshot below on what the design is supposed to look like.
There are these three overlays:
Straight angled shape with 0% transparency at bottom.
Outer circle with transparency.
Inner circle with transparency.
Here's what I have so far. I included a snippet below and also have a working version on Codepen. The circles are in the right place at bottom left.
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
svg {
width: 628;
height: 628:
}
.element {
position: relative;
width: 100%;
min-height: 628px;
background: url(https://images-prod.healthline.com/hlcmsresource/images/AN_images/health-benefits-of-apples-1296x728-feature.jpg) no-repeat center top;
background-size: cover;
}
.element:before{
content: '';
position: absolute; bottom: 0; left: 0;
width: 100%;0
-webkit-clip-path: polygon(0 0, 0% 100%, 100% 100%);
clip-path: polygon(0 0, 0% 100%, 100% 100%);
}
.circle-outer {
cx: 200;
cy: 720;
fill: #fff;
fill-opacity: 0.6;
r: 420;
w: 628;
h: 628;
}
.circle-inner {
cx: 200;
cy: 720;
fill: #fff;
fill-opacity: 0.6;
r: 400;
}
.hero-triangle {
content: '';
position: relative;
width: 100%;
height: 100px;
background: #fff;
-webkit-clip-path: polygon(0 8%, 0% 100%, 100% 100%);
clip-path: polygon(0 80%, 0% 100%, 100% 100%);
z-index: 99;
}
<div class="container">
<div class="element">
<div class="hero-content">
<h1>This belongs in circle</h1>
<p>This belongs in circle too.</p>
<button class="btn btn-primary">Learn more</button>
</div>
<svg viewbox width="1000" height="580" viewBox="0 0 100 100">
<circle class="circle-outer" />
<circle class="circle-inner" />
<polygon points="0,0 0,200 1000,200" style="fill:#fff;" />
</svg>
</div>
</div>
<div class="container">
<h4>Body content must be positioned right underneath hero image for all widths.</h4>
As the circles are just decorative rather than adding meaning there is no need for them to be elements. It will be sufficient for them to be background-images.
Here is a simple snippet which places the content element and gives it two acckground-images, both with some transparency, making them circles using radial-gradients.
.element {
position: relative;
width: 100%;
rmin-height: 628px;
background: url(https://images-prod.healthline.com/hlcmsresource/images/AN_images/health-benefits-of-apples-1296x728-feature.jpg) no-repeat center top;
background-size: cover;
clip-path: polygon(0 0, 0 80%, 100% 100%, 100% 0);
aspect-ratio: 1296 / 728;
}
.hero-content {
position: absolute;
left: -12.5%;
top: 50%;
width: 70%;
padding-top: 5%;
box-sizing: border-box;
aspect-ratio: 1 / 1;
background-image: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0 65%, transparent 65% 100%), radial-gradient(circle, rgba(255, 255, 255, 0.2) 0 70%, transparent 70% 100%);
background-repeat: no-repeat;
background-size: 100% 100%;
display: flex;
align-items: center;
rjustify-content: center;
flex-direction: column;
}
.hero-content h1 {
font-size: 2vw;
}
.hero-content p {
font-size: 1vw;
}
.hero-content button {
font-size: 1vw;
}
<div class="container">
<div class="element">
<div class="hero-content">
<h1>This belongs in circle</h1>
<p>This belongs in circle too.</p>
<button class="btn btn-primary">Learn more</button>
</div>
<!--<svg viewbox width="1000" height="580" viewBox="0 0 100 100">
<circle class="circle-outer" />
<circle class="circle-inner" />
<polygon points="0,0 0,200 1000,200" style="fill:#fff;" />
</svg>
-->
</div>
</div>
<div class="container">
<h4>Body content must be positioned right
Note: obviously you will want to change the settings for type sizes to suit your particular use case. I just made them relative to the viewport so that it is responsive.
Also, there is some confusion I think between whether it is essential for the hero to cover the full width or for the min height to be set. Of course revert to that if that is what is required, the circles will just be in a different place relative to the apples and some of the image may disappear.
Instead of mixing in a SVG element you could just use CSS to create the circle.
* {
padding: 0;
margin: 0;
}
.element {
position: relative;
width: 100%;
min-height: 628px;
background: url(https://images-prod.healthline.com/hlcmsresource/images/AN_images/health-benefits-of-apples-1296x728-feature.jpg) no-repeat center top;
background-size: cover;
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 90%);
}
.hero-content {
position: absolute;
left: -50px;
bottom: -200px;
border-radius: 50%;
border: solid rgba(255, 255, 255, .2) 1em;
}
.hero-content>div {
width: 300px;
height: 300px;
border-radius: 50%;
text-align: center;
padding: 5em;
background-color: rgba(255, 255, 255, .5);
}
<div class="container">
<div class="element">
<div class="hero-content">
<div>
<h1>This belongs in circle</h1>
<p>This belongs in circle too.</p>
<button class="btn btn-primary">Learn more</button>
</div>
</div>
</div>
</div>
<div class="container">
<h4>Body content must be positioned right underneath hero image for all widths.</h4>
</div>
The z-index of the triangle is 99, meaning it will be on top all other content in the page that has no z-index or z-index greater than 99. So just set the z-index to -1.
And besides, there's nothing like hero-triagle in your html, it's not the hero-triagle that's affecting your code, if I'm seeing the right thing here, it's the clip-path in the element, comments it out and see the changes.

How to have transparent scooped corners? [duplicate]

I would like to make a transparent cut out half circle shape using only CSS3. The only requirement is that all the elements that form the shape must be black or transparent.
I cannot use a black rectangle with a white circle on top of it because the half circle has to be transparent and let the background show through.
Desired shape :
May be can do it with CSS :after pseudo property like this:
body {
background: green;
}
.rect {
height: 100px;
width: 100px;
background: rgba(0, 0, 0, 0.5);
position: relative;
margin-top: 100px;
margin-left: 100px;
}
.circle {
display: block;
width: 100px;
height: 50px;
top: -50px;
left: 0;
overflow: hidden;
position: absolute;
}
.circle:after {
content: '';
width: 100px;
height: 100px;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 100px;
background: rgba(0, 0, 0, 0);
position: absolute;
top: -100px;
left: -40px;
border: 40px solid rgba(0, 0, 0, 0.5);
}
<div class="rect"> <span class="circle"></span></div>
View on JSFiddle
You can use box-shadows to make the transparent cut out circle :
body {
background: url(http://i.imgur.com/qi5FGET.jpg) no-repeat;
background-size: cover;
}
div {
display: inline-block;
width: 300px; height: 300px;
position: relative;
overflow: hidden;
}
div:before {
content: '';
position: absolute;
bottom: 50%;
width: 100%; height: 100%;
border-radius: 100%;
box-shadow: 0px 300px 0px 300px #000;
}
.transparent {
opacity: 0.5;
}
<div></div>
<div class="transparent"></div>
This can be responsive with percentage lengths:
body {
background: url(http://lorempixel.com/output/people-q-c-640-480-1.jpg) no-repeat;
background-size: cover;
}
div {
width: 40%; height: 300px;
position: relative;
overflow: hidden;
}
div:before {
content: '';
position: absolute;
bottom: 50%;
width: 100%; height: 100%;
border-radius: 100%;
box-shadow: 0px 300px 0px 300px #000;
}
.transparent {
opacity: 0.5;
}
<div class="transparent"></div>
Using SVG:
Here is an alternate solution using SVG (though you haven't tagged it). Advantages of using SVG are:
It has better browser support when compared to radial-gradients.
SVG can support images inside the shape unlike the box-shadow approach.
While SVG is not supported by <= IE8 whereas box-shadow is, fallbacks can be provided.
svg {
height: 150px;
width: 150px;
}
polygon {
fill: black;
}
/* Just for demo */
body {
background-image: radial-gradient(circle, #3F9CBA 0%, #153346 100%);
}
<!-- Sample 1 - Using Clip Path -->
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<defs>
<clipPath id='clipper'>
<path d='M0,0 a50,50 0 1,0 100,0 l 0,100 -100,0' />
</clipPath>
</defs>
<polygon points='0,0 100,0 100,100 0,100' clip-path='url(#clipper)' />
</svg>
<!-- Sample 2 - Using Path -->
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<pattern id='bg' width='100' height='100' patternUnits='userSpaceOnUse'>
<image xlink:href='http://lorempixel.com/100/100/nature/1' height='100' width='100' />
</pattern>
<path d='M0,0 a50,50 0 1,0 100,0 l 0,100 -100,0 0,-100' fill='url(#bg)' />
</svg>
Using CSS:
CSS also has clip-path specifications and we can try something like in the below snippet.
.shape {
position: relative;
width: 100px;
height: 100px;
background-color: purple;
}
.shape:after {
position: absolute;
content: '';
top: 0px;
left: 0px;
height: 100%;
width: 100%;
background: white;
-webkit-clip-path: ellipse(50% 20% at 50% 0%);
clip-path: ellipse(50% 20% at 50% 5%);
}
.shape.image{
background: url(http://lorempixel.com/100/100);
}
#shape-2 {
width: 100px;
height: 100px;
background-color: purple;
-webkit-clip-path: ellipse(50% 20% at 50% 20%);
clip-path: ellipse(50% 20% at 50% 20%);
}
/* Just for demo */
.shape{
float: left;
margin: 20px;
}
#shape-2 {
margin: 150px 20px 0px;
}
<div class="shape"></div>
<div class="shape image"></div>
<br/>
<div id="shape-2"></div>
But unlike SVG clip-path, the pure CSS version (that is, without using an inline or external SVG) doesn't seem to be able to support a path. It only supports shapes and so in this case, if you use the clip-path on the parent directly it would just produce an ellipse (like shown in the snippet). To overcome this, we would have to put the clip-path on a child (or a pseudo element) and this would mean that the clipped area would not be transparent.
Using Canvas:
The same can be done using Canvas also. Canvas commands are pretty similar to SVG and their advantages are also pretty similar. However, Canvas are raster based and hence doesn't scale as well as SVG does.
window.onload = function() {
/* Canvas example with path */
var canvas = document.getElementById('canvas');
if (canvas.getContext) {
var ctx = canvas.getContext('2d');
var img = new Image();
img.src = 'http://lorempixel.com/150/300';
ctx.beginPath();
ctx.moveTo(110, 0);
ctx.arc(60, 0, 50, 0, 3.14, false);
ctx.lineTo(10, 145);
ctx.lineTo(110, 145);
ctx.closePath();
ctx.fill();
/* Use below for using image as a fill */
/*img.onload = function(){
var ptrn = ctx.createPattern(img,'no-repeat');
ctx.fillStyle = ptrn;
ctx.fill();
}*/
}
/* Canvas example with clip path */
var canvasClip = document.getElementById('canvas-clip');
if (canvasClip.getContext) {
var ctxClip = canvasClip.getContext('2d');
ctxClip.beginPath();
ctxClip.moveTo(10, 145);
ctxClip.lineTo(10, 0);
ctxClip.arc(60, 0, 50, 0, Math.PI * 2, true);
ctxClip.lineTo(110, 145);
ctxClip.lineTo(10, 145);
ctxClip.clip();
ctxClip.fillStyle = 'tomato';
ctxClip.fill();
}
}
canvas {
height: 150px;
width: 300px;
}
/* Just for demo */
body {
background-image: radial-gradient(circle, #3F9CBA 0%, #153346 100%);
}
<canvas id='canvas'></canvas>
<canvas id='canvas-clip'></canvas>
Using Masks:
This shape can be created by using CSS (or) SVG masks also. CSS masks have very poor support and work currently only in Webkit powered browsers but SVG masks have much better support and should work in IE9+.
/* CSS Mask */
.shape {
width: 150px;
height: 150px;
background-color: black;
-webkit-mask-image: radial-gradient(circle closest-corner at 50% 0%, transparent 98%, white 99%);
mask-image: radial-gradient(circle closest-corner at 50% 0%, transparent 98%, white 99%);
}
/* End of CSS Mask */
svg {
height: 150px;
width: 150px;
}
polygon#shape {
fill: black;
mask: url(#masker);
}
/* Just for demo */
body {
background-image: radial-gradient(circle, #3F9CBA 0%, #153346 100%);
}
<!-- CSS Mask -->
<div class='shape'></div>
<!-- SVG Mask -->
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<defs>
<mask id='masker' x='0' y='0' width='100' height='100'>
<polygon points='0,0 100,0 100,100 0,100' fill='#fff' />
<circle r='50' cx='50' cy='0' fill='#000' />
</mask>
</defs>
<polygon points='0,0 100,0 100,100 0,100' id='shape' />
</svg>
You can do it really easily with a radial gradient.
DEMO
Result:
HTML:
<div class='shape'></div>
Relevant CSS:
.shape {
margin: 0 auto;
width: 10em; height: 16em;
/* WebKit browsers, old syntax */
background: -webkit-radial-gradient(50% 0, circle, transparent 30%, black 30%);
/* IE10, current versions of Firefox and Opera */
background: radial-gradient(circle at 50% 0, transparent 30%, black 30%);
}
See http://caniuse.com/#feat=css-gradients for detailed info on compatibility.
Try this.
body{
background-color:#333;
passing:0px;
height:0px;
}
#app{
background:#333 url('https://source.unsplash.com/random') no-repeat;
background-size:cover;
width:360px;
height:560px;
position:relative;
overflow:hidden;
}
.app-bar{
width:100%;
height:50px;
position:absolute;
bottom:0px;
left:0;
}
.app-bar .bar{
line-height:50px;
position:relative;
width:100%;
height:50px;
background-image: radial-gradient(circle 35px at 315px 0, transparent 700px, #f44336 50px);
}
.app-bar .bar i{
color:#FFF;
display:block;
line-height:50px;
float:left;
width:50px;
text-align:center;
cursor:pointer;
margin-top:0px;
}
.app-bar .bar i:hover{
background-color:rgba(0,0,0,.1);
}
.app-bar .bar button{
padding:0px;
box-sizing:border;
text-align:center;
margin:0px;
bordeR:0px;
outline:0px;
width:60px;
height:60px;
line-height:60px;
cursor:pointer;
color:#FFFFFF;
display:block;
border-radius:50%;
position:absolute;
top:-30px;
left:100%;
margin-left:-75px;
background-color:#f44336;
transition: all .2s ease;
}
.app-bar .bar button span{
line-height:60px;
font-size:30px;
}
.app-bar .bar button:hover{
transform:rotate(45deg);
transition: all .2s ease;
}
<div id="app">
<div class="app-bar">
<div class="bar">
<i class="material-icons">menu</i>
<i class="material-icons">search</i>
<button class="button">
<span class="material-icons">add</span>
</button>
</div>
</div>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/material-design-icons/3.0.1/iconfont/material-icons.min.css" >
Kyle Sevenokas did some good work. And I built off of that. Checkout the http://jsfiddle.net/FcaVX/1/
I basically collapsed the white div for the circle and gave it white borders. The OP question talked about the colors elements that make up the shape; nothing about its borders right?
I needed rounded corners only on the bottom of a responsive image. I started from #sandeep fiddle and improved it for my needs:
.rect
{
height: 85vh;
position: relative;
background-color: red;
width: 60vw;
}
.circle-helper{
display: block;
width: 100%;
padding-bottom: 50%;
bottom: 0;
left: 0;
overflow: hidden;
position: absolute;
background-color: transparent;
}
.circle{
display: block;
width: 100%;
padding-bottom: 100%;
// height: 500px;
bottom: 0;
left: 0;
overflow: hidden;
position: absolute;
background-color: transparent;
}
.circle:after{
box-sizing: content-box;
content: '';
width: 100%;
height: 100%;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
background: rgba(0,0,0,0);
position: absolute;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
border: 300px solid blue;
}
top: 50%
left: 50%
border: 300px solid blue
https://jsfiddle.net/mop00j22/
Right now, the only way I can think of would be to use a lot of 1-pixel wide black divs next to eachother with varying height. It's technically possible this way but should be deeply frowned upon. Also; you won't have anti-aliassing unless you want to go through the trouble of adding 1x1 pixel divs and do the anti-aliassing manually.
It might be more helpful if you gave an example of how you wanted to use this. Why does it need to be black/transparent only? As stated by omarello, the best solution on most circumstances is probably a simple GIF or PNG image with transparency.

CSS - Add a hexagonal border on text [duplicate]

I'm trying to create two elongated hexagons in like:
The main features should be:
possibility to add a gradient background
possibility to add a gradient border
text could be two-lined or single-lined
responsive in a Bootstrap-grid (nice to have) - angles of corners should be always the same.
According to Elongated hexagon shaped button using only one element the best solution so far is like
https://jsfiddle.net/veuc78af/:
/*hexagons*/
.hexagon {
box-sizing: border-box;
position: relative;
display: inline-block;
min-width: 200px;
height: 80px;
margin: 40px auto;
color: #fd0;
text-align: center;
text-decoration: none;
line-height: 80px;
}
.hexagon:before, .hexagon:after {
position: absolute;
content:'';
width: 100%;
left: 0px;
height: 34px;
z-index: -1;
}
.hexagon:before {
transform: perspective(15px) rotateX(3deg);
}
.hexagon:after {
top: 40px;
transform: perspective(15px) rotateX(-3deg);
}
/* hexagon Border Style */
.hexagon.border:before, .hexagon.border:after {
border: 4px solid #fd0;
}
.hexagon.border:before {
border-bottom: none;
/* to prevent the border-line showing up in the middle of the shape */
}
.hexagon.border:after {
border-top: none;
/* to prevent the border-line showing up in the middle of the shape */
}
/* hexagon hover styles */
.hexagon.border:hover:before, .hexagon.border:hover:after {
background: #fd0;
}
.hexagon.border:hover {
color: #fff;
}
The main problem with this solution is that it isn't possible to create a gradient background. So this isn't working in my case.
Is there any possibility to do that?
The main platform for this project is Safari on an iPad2.
Using CSS Clip Path:
The main platform for this project is Safari on an iPad2.
Since, your main platform is Safari and it does support CSS clip-path with shapes, you can make use of that feature to create the elongated hexagons like in the below demo.
Output produced by this approach will support (a) gradient backgrounds (b) a gradient border which is mimicked by placing a pseudo-element with a very similar clip-path but smaller dimensions (c) two lines of text (d) also maintain the angles of the corners because the points are at a fixed px distance.
.hex {
position: relative;
float: left;
height: 100px;
min-width: 100px;
padding: 12px;
margin: 4px;
font-weight: bold;
text-align: center;
background: linear-gradient(to right, rgb(199, 41, 41), rgb(243, 67, 54));
-webkit-clip-path: polygon(25px 0px, calc(100% - 25px) 0px, 100% 50%, calc(100% - 25px) 100%, 25px 100%, 0px 50%);
}
.hex.gradient-bg {
color: white;
}
.hex.gradient-border {
color: rgb(199, 41, 41);
}
.hex:before {
position: absolute;
content: '';
height: calc(100% - 14px); /* 100% - 2 * border width */
width: calc(100% - 14px); /* 100% - 2 * border width */
left: 7px; /* border width */
top: 7px; /* border width */
-webkit-clip-path: polygon(22px 0px, calc(100% - 22px) 0px, 100% 50%, calc(100% - 22px) 100%, 22px 100%, 0px 50%);
z-index: -1;
}
.hex.gradient-bg:before {
background: linear-gradient(to right, rgb(199, 41, 41), rgb(243, 67, 54));
}
.hex.gradient-border:before {
background: rgb(245, 246, 248);
}
span {
display: block;
margin-top: 50px;
padding: 8px;
transform: translateY(-50%);
}
<div class='hex gradient-border'>
<span>Some text</span>
</div>
<div class='hex gradient-bg'>
<span>Some very lengthy text</span>
</div>
<div class='hex gradient-bg'>
<span>Some very lengthy text
<br/>with line break</span>
</div>
<div class='hex gradient-bg'>
<span>Some very lengthy text
without line break</span>
</div>
Using SVG:
The same can be done using SVG also like in the below demo. It just requires a path to be created in the form of a hexagon and then for that path image to be placed behind the container.
The only drawback is that unlike CSS clip-path there is no non-JS way to get the angles to stay the same.
.hex {
position: relative;
height: 100px;
min-width: 100px;
padding: 12px 24px;
margin: 4px;
float: left;
font-weight: bold;
text-align: center;
}
.hex.gradient-bg {
color: white;
}
.hex.gradient-border {
color: rgb(199, 41, 41);
}
.hex svg {
position: absolute;
height: 100%;
width: 100%;
top: 0px;
left: 0px;
z-index: -1;
}
path {
stroke: url(#brdgrad);
stroke-width: 7; /* border width */
}
.hex.gradient-bg path {
fill: url(#bggrad);
}
.hex.gradient-border path {
fill: rgb(245, 246, 248);
}
span {
display: block;
margin-top: 50px;
padding: 8px;
transform: translateY(-50%);
}
<svg width='0' height='0'>
<defs>
<linearGradient id='bggrad'>
<stop offset='0%' stop-color='rgb(199, 41, 41)' />
<stop offset='100%' stop-color='rgb(243, 67, 54)' />
</linearGradient>
<linearGradient id='brdgrad'>
<stop offset='0%' stop-color='rgb(199, 41, 41)' />
<stop offset='100%' stop-color='rgb(243, 67, 54)' />
</linearGradient>
</defs>
</svg>
<div class='hex gradient-border'>
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<path d='M25,7 L75,7 93,50 75,93 25,93 7,50z' vector-effect='non-scaling-stroke' />
</svg>
<span>Some text</span>
</div>
<div class='hex gradient-bg'>
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<path d='M25,7 L75,7 93,50 75,93 25,93 7,50z' vector-effect='non-scaling-stroke' />
</svg>
<span>Some very lengthy text</span>
</div>
<div class='hex gradient-bg'>
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<path d='M25,7 L75,7 93,50 75,93 25,93 7,50z' vector-effect='non-scaling-stroke' />
</svg>
<span>Some very lengthy text
<br>with line break.</span>
</div>
<div class='hex gradient-bg'>
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<path d='M25,7 L75,7 93,50 75,93 25,93 7,50z' vector-effect='non-scaling-stroke' />
</svg>
<span>Some lengthy text
without line break.</span>
</div>
(Don't be put off by how lengthy the SVG code is, it is so big only because I've repeated it more than once - once for each container. That can be reduced.)
.hexagon {
position: relative;
width: 180px;
height: 103.92px;
background-color: #ffffff;
margin: 51.96px 0;
border-left: solid 5px #808080;
border-right: solid 5px #808080;
}
.hexagon:before,
.hexagon:after {
content: "";
position: absolute;
z-index: 1;
width: 127.28px;
height: 127.28px;
-webkit-transform: scaleY(0.5774) rotate(-45deg);
-ms-transform: scaleY(0.5774) rotate(-45deg);
transform: scaleY(0.5774) rotate(-45deg);
background-color: inherit;
left: 21.3604px;
}
.hexagon:before {
top: -63.6396px;
border-top: solid 7.0711px #808080;
border-right: solid 7.0711px #808080;
}
.hexagon:after {
bottom: -63.6396px;
border-bottom: solid 7.0711px #808080;
border-left: solid 7.0711px #808080;
}
.hexText{
position: absolute;
top: 59px;
z-index: 999;
left: 12%;
text-align:center;
}
.bgGrey{
background:#e7e6e6 !important;
}
<div class="row">
<div class="col-md-3 col-xs-12">
<div class="hexagon"></div>
<p class="hexText">Up to 20% increase<br />in sales with<br />Cross sell & Up sell</p>
</div>
<div class="col-md-3 col-xs-12">
<div class="hexagon bgGrey"></div>
<p class="hexText">Up to 35%reduction<br />in print ,postage ,<br />logistic & back<br />office cost</p>
</div>
<div class="col-md-3 col-xs-12">
<div class="hexagon"></div>
<p class="hexText">Scalable100+million <br />statements<br />processed & <br />distributed monthly </p>
</div>
<div class="col-md-3 col-xs-12">
<div class="hexagon bgGrey"></div>
<p class="hexText">Up to 35%reduction<br />in print ,postage ,<br />logistic & back<br />office cost</p>
</div>
</div>

CSS: Responsive elongated hexagon with text and gradient background/border

I'm trying to create two elongated hexagons in like:
The main features should be:
possibility to add a gradient background
possibility to add a gradient border
text could be two-lined or single-lined
responsive in a Bootstrap-grid (nice to have) - angles of corners should be always the same.
According to Elongated hexagon shaped button using only one element the best solution so far is like
https://jsfiddle.net/veuc78af/:
/*hexagons*/
.hexagon {
box-sizing: border-box;
position: relative;
display: inline-block;
min-width: 200px;
height: 80px;
margin: 40px auto;
color: #fd0;
text-align: center;
text-decoration: none;
line-height: 80px;
}
.hexagon:before, .hexagon:after {
position: absolute;
content:'';
width: 100%;
left: 0px;
height: 34px;
z-index: -1;
}
.hexagon:before {
transform: perspective(15px) rotateX(3deg);
}
.hexagon:after {
top: 40px;
transform: perspective(15px) rotateX(-3deg);
}
/* hexagon Border Style */
.hexagon.border:before, .hexagon.border:after {
border: 4px solid #fd0;
}
.hexagon.border:before {
border-bottom: none;
/* to prevent the border-line showing up in the middle of the shape */
}
.hexagon.border:after {
border-top: none;
/* to prevent the border-line showing up in the middle of the shape */
}
/* hexagon hover styles */
.hexagon.border:hover:before, .hexagon.border:hover:after {
background: #fd0;
}
.hexagon.border:hover {
color: #fff;
}
The main problem with this solution is that it isn't possible to create a gradient background. So this isn't working in my case.
Is there any possibility to do that?
The main platform for this project is Safari on an iPad2.
Using CSS Clip Path:
The main platform for this project is Safari on an iPad2.
Since, your main platform is Safari and it does support CSS clip-path with shapes, you can make use of that feature to create the elongated hexagons like in the below demo.
Output produced by this approach will support (a) gradient backgrounds (b) a gradient border which is mimicked by placing a pseudo-element with a very similar clip-path but smaller dimensions (c) two lines of text (d) also maintain the angles of the corners because the points are at a fixed px distance.
.hex {
position: relative;
float: left;
height: 100px;
min-width: 100px;
padding: 12px;
margin: 4px;
font-weight: bold;
text-align: center;
background: linear-gradient(to right, rgb(199, 41, 41), rgb(243, 67, 54));
-webkit-clip-path: polygon(25px 0px, calc(100% - 25px) 0px, 100% 50%, calc(100% - 25px) 100%, 25px 100%, 0px 50%);
}
.hex.gradient-bg {
color: white;
}
.hex.gradient-border {
color: rgb(199, 41, 41);
}
.hex:before {
position: absolute;
content: '';
height: calc(100% - 14px); /* 100% - 2 * border width */
width: calc(100% - 14px); /* 100% - 2 * border width */
left: 7px; /* border width */
top: 7px; /* border width */
-webkit-clip-path: polygon(22px 0px, calc(100% - 22px) 0px, 100% 50%, calc(100% - 22px) 100%, 22px 100%, 0px 50%);
z-index: -1;
}
.hex.gradient-bg:before {
background: linear-gradient(to right, rgb(199, 41, 41), rgb(243, 67, 54));
}
.hex.gradient-border:before {
background: rgb(245, 246, 248);
}
span {
display: block;
margin-top: 50px;
padding: 8px;
transform: translateY(-50%);
}
<div class='hex gradient-border'>
<span>Some text</span>
</div>
<div class='hex gradient-bg'>
<span>Some very lengthy text</span>
</div>
<div class='hex gradient-bg'>
<span>Some very lengthy text
<br/>with line break</span>
</div>
<div class='hex gradient-bg'>
<span>Some very lengthy text
without line break</span>
</div>
Using SVG:
The same can be done using SVG also like in the below demo. It just requires a path to be created in the form of a hexagon and then for that path image to be placed behind the container.
The only drawback is that unlike CSS clip-path there is no non-JS way to get the angles to stay the same.
.hex {
position: relative;
height: 100px;
min-width: 100px;
padding: 12px 24px;
margin: 4px;
float: left;
font-weight: bold;
text-align: center;
}
.hex.gradient-bg {
color: white;
}
.hex.gradient-border {
color: rgb(199, 41, 41);
}
.hex svg {
position: absolute;
height: 100%;
width: 100%;
top: 0px;
left: 0px;
z-index: -1;
}
path {
stroke: url(#brdgrad);
stroke-width: 7; /* border width */
}
.hex.gradient-bg path {
fill: url(#bggrad);
}
.hex.gradient-border path {
fill: rgb(245, 246, 248);
}
span {
display: block;
margin-top: 50px;
padding: 8px;
transform: translateY(-50%);
}
<svg width='0' height='0'>
<defs>
<linearGradient id='bggrad'>
<stop offset='0%' stop-color='rgb(199, 41, 41)' />
<stop offset='100%' stop-color='rgb(243, 67, 54)' />
</linearGradient>
<linearGradient id='brdgrad'>
<stop offset='0%' stop-color='rgb(199, 41, 41)' />
<stop offset='100%' stop-color='rgb(243, 67, 54)' />
</linearGradient>
</defs>
</svg>
<div class='hex gradient-border'>
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<path d='M25,7 L75,7 93,50 75,93 25,93 7,50z' vector-effect='non-scaling-stroke' />
</svg>
<span>Some text</span>
</div>
<div class='hex gradient-bg'>
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<path d='M25,7 L75,7 93,50 75,93 25,93 7,50z' vector-effect='non-scaling-stroke' />
</svg>
<span>Some very lengthy text</span>
</div>
<div class='hex gradient-bg'>
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<path d='M25,7 L75,7 93,50 75,93 25,93 7,50z' vector-effect='non-scaling-stroke' />
</svg>
<span>Some very lengthy text
<br>with line break.</span>
</div>
<div class='hex gradient-bg'>
<svg viewBox='0 0 100 100' preserveAspectRatio='none'>
<path d='M25,7 L75,7 93,50 75,93 25,93 7,50z' vector-effect='non-scaling-stroke' />
</svg>
<span>Some lengthy text
without line break.</span>
</div>
(Don't be put off by how lengthy the SVG code is, it is so big only because I've repeated it more than once - once for each container. That can be reduced.)
.hexagon {
position: relative;
width: 180px;
height: 103.92px;
background-color: #ffffff;
margin: 51.96px 0;
border-left: solid 5px #808080;
border-right: solid 5px #808080;
}
.hexagon:before,
.hexagon:after {
content: "";
position: absolute;
z-index: 1;
width: 127.28px;
height: 127.28px;
-webkit-transform: scaleY(0.5774) rotate(-45deg);
-ms-transform: scaleY(0.5774) rotate(-45deg);
transform: scaleY(0.5774) rotate(-45deg);
background-color: inherit;
left: 21.3604px;
}
.hexagon:before {
top: -63.6396px;
border-top: solid 7.0711px #808080;
border-right: solid 7.0711px #808080;
}
.hexagon:after {
bottom: -63.6396px;
border-bottom: solid 7.0711px #808080;
border-left: solid 7.0711px #808080;
}
.hexText{
position: absolute;
top: 59px;
z-index: 999;
left: 12%;
text-align:center;
}
.bgGrey{
background:#e7e6e6 !important;
}
<div class="row">
<div class="col-md-3 col-xs-12">
<div class="hexagon"></div>
<p class="hexText">Up to 20% increase<br />in sales with<br />Cross sell & Up sell</p>
</div>
<div class="col-md-3 col-xs-12">
<div class="hexagon bgGrey"></div>
<p class="hexText">Up to 35%reduction<br />in print ,postage ,<br />logistic & back<br />office cost</p>
</div>
<div class="col-md-3 col-xs-12">
<div class="hexagon"></div>
<p class="hexText">Scalable100+million <br />statements<br />processed & <br />distributed monthly </p>
</div>
<div class="col-md-3 col-xs-12">
<div class="hexagon bgGrey"></div>
<p class="hexText">Up to 35%reduction<br />in print ,postage ,<br />logistic & back<br />office cost</p>
</div>
</div>