Quick Tip: Practical CSS Shapes
videos

Quick Tip: Practical CSS Shapes

Tutorial Details
  • Topic: CSS
  • Difficulty: Intermediate
  • Estimated Completion Time: 4 Minutes

A common design technique lately is to create a fold effect, where it appears as if a heading is wrapping behind its container. This is generally achieved through the use of tiny images; however, with CSS, we can mimic this effect quite easily. I’ll show you how in four minutes.

Example

Final HTML

<!DOCTYPE html>

<html lang="en">
<head>
	<meta charset="utf-8">
	<title>CSS Shapes</title>

	<!--[if IE]>
		<style>
			.arrow { top: 100%; }
		</style>
	<![endif]-->

</head>
<body>
	 <div id="container">

		<h1> My Heading <span class="arrow"></span> </h1>

	</div>
</body>
</html>

Final CSS

#container {
	background: #666;
	margin: auto;
	width: 500px;
	height: 700px;
	padding-top: 30px;
	font-family: helvetica, arial, sans-serif;
	}

h1 {
	 background: #e3e3e3;
	 background: -moz-linear-gradient(top, #e3e3e3, #c8c8c8);
	 background: -webkit-gradient(linear, left top, left bottom, from(#e3e3e3), to(#c8c8c8));
	 padding: 10px 20px;
	 margin-left: -20px;
	 margin-top: 0;
	 position: relative;
	 width: 70%;

	-moz-box-shadow: 1px 1px 3px #292929;
	-webkit-box-shadow: 1px 1px 3px #292929;
       box-shadow: 1px 1px 3px #292929;

	color: #454545;
	text-shadow: 0 1px 0 white;
}

.arrow {
	 width: 0; height: 0;
	 line-height: 0;
	 border-left: 20px solid transparent;
	 border-top: 10px solid #c8c8c8;
	 top: 104%;
	 left: 0;
	 position: absolute;
}

Add Comment

Discussion 132 Comments

Comment Page 3 of 3 1 2 3
  1. Mr-H says:

    thank you very much jeff, youre the best in css

  2. kim says:

    nice tutorial!

    but i have a question!

    if i want the “.arrow” class on the right side of the header to, how do i do?

    / kim

    • Chris says:

      If you want the arrow on the right side, change
      .arrow {
      width: 0; height: 0;
      line-height: 0;
      border-left: 20px solid transparent;
      border-top: 10px solid #c8c8c8;
      top: 104%;
      left: 0;
      position: absolute;
      }

      with:

      .arrow {
      width: 0; height: 0;
      line-height: 0;
      border-right: 20px solid transparent;
      border-top: 10px solid #c8c8c8;
      top: 104%;
      right: 0;
      position: absolute;
      }

  3. chongfai13 says:

    Thanks for the hard work. love it

  4. Joe Robison says:

    Wow you are kind of a css stud, I can’t believe you did it that fast….I learned so much.

  5. Nisal says:

    Nice tut on PSD TO HTML keep it up.

  6. Sam Burns says:

    If you want to set the H1 with some Opacity how do you make it so that the text has no opacity.

    I know how to do this with divs by setting a parent and child and setting the position:relativve, but how would you do this with and h1?

  7. Can we make this possible without using blank span?

    • Pablo Mendoza says:

      You can use h1:before, something like this:

      h1:before{
      content: ‘ ‘;
      position: relative;
      left: …;
      top: …;
      .
      .
      /*attributes for the arrow*/
      .
      }

  8. Steve says:

    Very nice. Another note to self….. Get the Edit CSS addon for Firefox. :)

  9. dendog says:

    please remove my previous comment (awesome! so much better than using images. thanks for the vid). i don’t want my image showing up on gravatar – sorry about that

  10. Ben M says:

    Is there any reason the arrow would duplicate itself below and to the right on a CSS layout? I’m a novice at this volunteering for a campaign. Thanks!

  11. marvelous says:

    Greetings,
    I really like ur tutorial. and i apriciate but could you make valid (CSS level 2.1) OR CSS3. IT SHOWS AN ERROR .i hope hearing from u soon . thank u

  12. Joe says:

    Thanks for this, works nicely on my site. Also works nicely with CSS PIE. ;)

  13. ndark says:

    Than you very nice tutorial..

  14. Henry CQ says:

    Nice tutorial !!!
    How do make the arrow located at top-right corner ?

  15. Heather Wood says:

    I really need to get a subscription to the tuts network. I have been trying to do this on my own and stumbled upon this by accident. You make it look so easy and I thank you for sharing with the world. Freelancers like me appreciate this so much ^_^

Comment Page 3 of 3 1 2 3

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.