Adding Round Corners to Web Page elements.

by Daniel Álvarez 15. October 2008 03:54

What are we facing?

I want to use border but not with square corners, instead I prefer to place rounded corners to my boxes.

The Solution

Actually it's impossible to create any kind of rounded shapes just with HTML and CSS code, that's why for this exercise we must need to use images to represent the corners of the boxes.

A new question is: What's the better way to introduce those images with our boxes? A very maintainable way to do this is by using the power of CSS.

We must create a normal text box with four corner images and with an image to repeatedly create the parallel lines of the box, as the following:

  • Insert the four images as background with CSS.

    Image with 4 backgrounds in the corners

    HTML code.

    <div class="c3"><div class ="c4"><div class="c1"><div class="c2">
       l'arte di apprendimento
    </div></div></div></div>

    CSS code.

    .c1 {background: url(c1.gif) 0 100% no-repeat}
    .c2 {background: url(c2.gif) 100% 100% no-repeat}
    .c3 {background: url(c3.gif) 0 0 no-repeat}
    .c4 {background: url(c4 .gif) 100% 0 no-repeat; padding:10px}
  • Add a border to the box (with more images).

    Image with 4 backgrounds in the corners and borders in the sides

    HTML code.

    <div class="l1"><div class="l2"><div class="l3"><div class="l4"><div class="c3"><div class ="c4"><div class="c1"><div class="c2">
       l'arte di apprendimento
    </div></div></div></div></div></div></div></div>

    CSS code.

    .l1 {background: url(dot.gif) repeat-x 0px 0px}
    .l2 {background: url(dot.gif) repeat-x 0px 100%}
    .l3 {background: url(dot.gif) repeat-y 0px 0px}
    .l4 {background: url(dot.gif) repeat-y 100% 0px}

Some external references

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

css | html | tips

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



About Aggiorno KC

Aggiorno RSS Feeds As Web developers, we are always hunting for pieces of wisdom spread all over the Web, by friends, by books, or both. Normally it requires time and effort to search and locate that wisdom and then even more to implement it. Knowledge Capsules provide you with a consolidated place to find all the specific pieces of code and advice you are commonly looking for, all provided by fellow Web developers.

IE8 Compatibility Wizard

Automatically upgrades your website to render correctly in IE8!

Internet Explorer 8 Compatibility Wizard

Get it today!


ArtinSoft Corporation ArtinSoft is Microsoft Certified Partner ISV/Software Solutions and Microsft Visual Studio Partner

With over fifteen years of experience, ArtinSoft has proven to be a key player in software evolution, by allowing customers from all over the world to ensure business continuity and compliance through software migration solutions and developer tools created upon principles of artificial intelligence. At present time, ArtinSoft Corporation remains a private firm in constant growth through a strategic partner network. Read More...