Download Coding : Document Icon Using CSS3
Here I would like to show you a neat trick to create a document icon with pure CSS3 only.
Step 1 : Create A Square Box
Just Add a single HTML element in the anchor tag and call the CSS.
<a class="docIcon" href="#">Document Icon</a>
.docIcon { background:#eee; background: linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%); border:1px solid #ccc; display:block; width:100px; height:100px; position:relative; margin:42px auto; } .docIcon { background: #eee; background: -webkit-linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%); background: -moz-linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%); background: -o-linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%); background: -ms-linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%); background: linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%); border: 1px solid #ccc; display: block; width: 40px; height: 56px; position: relative; margin: 42px auto; }
Next, let’s add some shine using CSS box shadows.And also I’ve also used the text-indent
property to hide the text.
.docIcon { -webkit-box-shadow:inset rgba(255,255,255,0.8) 0 1px 1px; -moz-box-shadow:inset rgba(255,255,255,0.8) 0 1px 1px; box-shadow:inset rgba(255,255,255,0.8) 0 1px 1px; text-indent:-9999em; }
Step 2 : Create a Rounded Corners
Next, we have to create a rounded corner effect. so Add the following coding in your css,
.docIcon { ... -webkit-border-radius:3px 18px 3px 3px; -moz-border-radius:3px 18px 3px 3px; border-radius:3px 18px 3px 3px; }
Then We would have like this
Step 3 : Create one Side Curled Corners
Here i have used CSS pseudo-elements.CSS pseudo-elements are used to add special effects to some selectors.
The syntax of pseudo-elements:
selector:pseudo-element {property:value;}
.docIcon:before { content: ""; display: block; position: absolute; top: 0; right: 0; width: 15px; height: 15px; background: #ccc; background: -webkit-linear-gradient(45deg, #fff 0, #eee 50%, #ccc 100%); background: -moz-linear-gradient(45deg, #fff 0, #eee 50%, #ccc 100%); background: -o-linear-gradient(45deg, #fff 0, #eee 50%, #ccc 100%); background: -ms-linear-gradient(45deg, #fff 0, #eee 50%, #ccc 100%); background: linear-gradient(45deg, #fff 0, #eee 50%, #ccc 100%); -webkit-box-shadow: rgba(0,0,0,0.05) -1px 1px 1px, inset white 0 0 1px; -moz-box-shadow: rgba(0,0,0,0.05) -1px 1px 1px, inset white 0 0 1px; box-shadow: rgba(0,0,0,0.05) -1px 1px 1px, inset white 0 0 1px; border-bottom: 1px solid #ccc; border-left: 1px solid #ccc; }
Then Add the top-right rounded edge to the curled rounded corners
-webkit-border-radius:3px 15px 3px 3px; -moz-border-radius:3px 15px 3px 3px; border-radius:3px 15px 3px 3px;
Atlast I got like this
Step 4 : Add the lines inside the rounded box
Next, I am going to use the
:after
psuedo element to add some dashed lines to represent zoomed out text.Add multiple lines using CSS3 Gradient.docIcon:after { content:""; display:block; position:absolute; left:0; top:0; width:60%; margin:22px 20% 0; height:15px; } .docIcon:after { ... background:#ccc; background: -webkit-linear-gradient(top, #ccc 0, #ccc 20%, #fff 20%, #fff 40%, #ccc 40%, #ccc 60%, #fff 60%, #fff 80%, #ccc 80%, #ccc 100%); background: -moz-linear-gradient(top, #ccc 0, #ccc 20%, #fff 20%, #fff 40%, #ccc 40%, #ccc 60%, #fff 60%, #fff 80%, #ccc 80%, #ccc 100%); background: -o-linear-gradient(top, #ccc 0, #ccc 20%, #fff 20%, #fff 40%, #ccc 40%, #ccc 60%, #fff 60%, #fff 80%, #ccc 80%, #ccc 100%); background: -ms-linear-gradient(top, #ccc 0, #ccc 20%, #fff 20%, #fff 40%, #ccc 40%, #ccc 60%, #fff 60%, #fff 80%, #ccc 80%, #ccc 100%); background:linear-gradient(top, #ccc 0, #ccc 20%, #fff 20%, #fff 40%, #ccc 40%, #ccc 60%, #fff 60%, #fff 80%, #ccc 80%, #ccc 100%); }
No comments:
Post a Comment