4

I would like to create this shape using just css. I am pretty sure this can be done. But i am having trouble with gradients involved.

This shape will contain some text inside. Suggested html markup is:

<div class="container">
    ... more html contents...
</div>

Shape to be created

A jsFiddle would be highly appreciated.
Thanks in advance.

2
  • What have you tried? How can you expect to draw an irregular shape like this, purely in CSS with no images? Commented Jul 6, 2012 at 15:15
  • it's that irregular if you see. i can be thought of as two rectangles. The big one is obvious. the smaller one at right top with with half the diagonal being transparent. just wondering if there is any technique i can follow to write the css for that. Commented Jul 6, 2012 at 15:20

3 Answers 3

9

Try this, http://jsfiddle.net/HshfF/1/

CSS: (From the fiddle in this comment)

.main {
    background: -moz-linear-gradient(top, #ffffff 0%, #e8e8e8 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e8e8e8)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #ffffff 0%,#e8e8e8 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #ffffff 0%,#e8e8e8 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #ffffff 0%,#e8e8e8 100%); /* IE10+ */
    background: linear-gradient(to bottom, #ffffff 0%,#e8e8e8 100%); /* W3C */
    position: relative;
    width: 150px;
    height: 100px;
    margin: 10px;
    border: 1px solid #d0d0d0;
    border-radius: 10px;
    padding: 20px;
}

.main:before {
    content: '';
    display: block;
    top: -1px;
    right: -1px;
    width: 20px;
    height: 20px;
    background: -moz-linear-gradient(top, #ffffff 0%, #e8e8e8 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e8e8e8)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #ffffff 0%,#e8e8e8 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #ffffff 0%,#e8e8e8 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #ffffff 0%,#e8e8e8 100%); /* IE10+ */
    background: linear-gradient(to bottom, #ffffff 0%,#e8e8e8 100%); /* W3C */
    position: absolute;
    border-radius: 0 0 0 5px;
    border-left: 1px solid #d0d0d0;
    border-bottom: 1px solid #d0d0d0;
}

.main:after {
    content: '';
    display: block;
    position: absolute;
    top: -1px;
    right: -1px;
    border-top: 20px solid #fff; 
    border-left: 20px solid transparent;
}
Sign up to request clarification or add additional context in comments.

5 Comments

i couldn;t figure out where to place the content. i should be able to place some content like <p> inside.
You could place content in the main div. And add some padding to it too. like so jsfiddle.net/HshfF/2
thanks...!! just eager to know do you think this can also be achieved using pseudo elements.'
Yep should be able to do it with using just :before
Here it is with using just pseudo elements, before and after. jsfiddle.net/HshfF/3
2

Please Learn CSS3, Try Nicholas Gallagher tutorials, he has some of the best css3 tutorials: one you looking for http://nicolasgallagher.com/pure-css-folded-corner-effect/demo/

The drop shadow and colors you looking for i think you need to do it yourself.

1 Comment

thanks... Let me go through 'em. colors obviously not of the big problem.
0

Nearly there with this: http://jsfiddle.net/Grezzo/52zG7/

You only need one div (thanks to pseudo element), but I haven't "cut" the corner yet.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.