I have to make a div
using HTML and CSS only but not using any background image with more than 4 corners.
How can I do it?
You can achieve this using single element and two gradients (one gradient for rectangle, another is for tab):
div {
width: 280px;
height: 200px;
background: linear-gradient(to bottom, transparent 31px, #656d78 31px),
linear-gradient(-135deg, transparent 32%, #656d78 32%);
}
<div></div>
Also this can be achieved via single gradient (for tab) using pseudoelement:
div {
width: 280px;
height: 169px;
background-color: #656d78;
margin-top: 39px;
position: relative;
}
div:after {
content: "";
position: absolute;
top: -31px;
left: 0;
width: 100%;
height: 31px;
background: linear-gradient(-135deg, transparent 50%, #656d78 50%);
}
<div></div>
You can use pseudo-element
and some css shape tricks to achieve this.
.folder {
width: 190px;
height: 110px;
background: #888;
position: relative;
overflow: hidden;
}
.folder:after {
content: "";
width: 100px;
border: 15px solid transparent;
position: absolute;
right: -15px;
border-top-color: #fff;
top:0;
}
<div class="folder"></div>
There are two examples of code: with CSS ( + animation ) and SVG.
With animation
* {
box-sizing: border-box;
}
html, body {
margin: 0;
padding: 0;
position: relative;
width: 100%;
height: 100%;
background-color: #2196f3;
}
.page {
height: 100%;
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
-moz-box-align: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
-moz-box-pack: center;
-ms-flex-pack: center;
}
.folder {
background-color: #d3eafd;
position: relative;
width: 92px;
height: 64px;
display: block;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
border-bottom-left-radius: 8px;
}
.folder-tab {
position: absolute;
height: 10px;
left: 0;
bottom: 100%;
display: block;
width: 40%;
border-top-left-radius: 8px;
background-color: inherit;
}
.folder-tab:after {
content: '';
position: absolute;
display: block;
top: 0;
left: calc(100% - 10px);
border-bottom: 10px solid #d3eafd;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
}
.folder-icn {
padding-top: 12px;
width: 100%;
height: 100%;
display: block;
}
.downloading {
width: 30px;
height: 32px;
margin: 0 auto;
position: relative;
overflow: hidden;
}
.custom-arrow {
width: 14px;
height: 14px;
position: absolute;
top: 0;
left: 50%;
margin-left: -7px;
background-color: #fff;
-webkit-animation-name: downloading;
-webkit-animation-duration: 1.5s;
-webkit-animation-iteration-count: infinite;
animation-name: downloading;
animation-duration: 1.5s;
animation-iteration-count: infinite;
}
.custom-arrow:after {
content: '';
position: absolute;
display: block;
top: 100%;
left: -9px;
border-top: 15px solid #fff;
border-left: 16px solid transparent;
border-right: 16px solid transparent;
}
.bar {
width: 30px;
height: 4px;
background-color: #fff;
margin: 0 auto;
}
@-webkit-keyframes downloading {
0% {
top: 0;
opacity: 1;
}
50% {
top: 110%;
opacity: 0;
}
52% {
top: -110%;
opacity: 0;
}
100% {
top: 0;
opacity: 1;
}
}
@keyframes downloading {
0% {
top: 0;
opacity: 1;
}
50% {
top: 110%;
opacity: 0;
}
52% {
top: -110%;
opacity: 0;
}
100% {
top: 0;
opacity: 1;
}
}
<div class="page">
<div class="folder">
<span class="folder-tab"></span>
<div class="folder-icn">
<div class="downloading">
<span class="custom-arrow"></span>
</div>
<div class="bar"></div>
</div>
</div>
</div>
SVG
<!DOCTYPE html>
<html>
<body>
<svg height="32px" version="1.1" viewBox="0 0 32 32" width="32px" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><title/><desc/><defs/><g fill="none" fill-rule="evenodd" id="Page-1" stroke="none" stroke-width="1"><g fill="#157EFB" id="icon-94-folder"><path d="M17,11 L15,7 L4.00276013,7 C2.89666625,7 2,7.88967395 2,8.991155 L2,27.008845 C2,28.1085295 2.89971268,29 3.99328744,29 L29.0067126,29 C30.1075748,29 31,28.1073772 31,27.0049107 L31,12.9950893 C31,11.8932319 30.1029399,11 28.9941413,11 L17,11 Z" id="folder"/></g></g>
</svg>
</body>
</html>
Helpful links:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With