Center for Digital Imaging Arts, Boston UniversityWaltham MA CampussplitWaltham MA Campus
Blog - Center for Digital Imaging Arts at Boston University
    Come connect with Boston University CDIA on Facebook so you can find out more about our certificate program in Audio engineering Boston University Certificate in Web Development can be found on LinkedIn Get updates surrounding our 3D animation program and certificate on twitter See the fantastic video work that our digital filmmaking certificate students create in film school at Boston University Center for Digtial Imaging Arts digital filmmaking certificate at Boston University Center for Digital Imaging Arts
CDIA Blog

Web Development

Rounded Corners With or Without Images

October 19, 2010 Often the websites I build for clients include rounded corners in the design. The border-radius property introduced by CSS3 and supported by most browsers except IE6-8, makes it easy to implement rounded corners.

Reprinted from http://professionaldilettante.com with permission from Zach Hannes

For those of you who just want to see the code: Rounded corners with background-images and Rounded corners using border-radius . The code below is somewhat pseudo code. The working demo code is here.

Before CSS3 Often the websites I build for clients include rounded corners in the design. Prior to CSS3, creating rounded corners ( without JavaScript ) in any browser required creating and slicing up images to be used with html elements and the css property, background-image. How many images need to be cut? How many elements do we need in our HTML mark-up to properly display the background-image? Other than background-image, what CSS properties are required to display the background-images? Those answers depends on whether you require the content to be able to expand and contract, or whether the height and width are fixed.

E.g., Rounded corners for the chrome of a webpage might need three background images and three HTML divs – div#top, div#center (repeating vertically), and div#bottom. Repeating the center background image allows for content of varying length. If you have a fixed height and width then you can cut a single background-image.

To boot, IE6 does not include native support for PNG images. So if your rounded corners required transparency, you needed separate background images and CSS rules to specify GIFs for IE6 and PNGs for IE7+ and other browsers. In order to apply rules specifically to IE6, you need detect the browser on the server side, use Microsoft proprietary conditional comments for Internet Explorer, or javascript. Alternatively, you can use the proprietary Microsoft filtering code to add support for transparent PNGs in IE6. Either way it requires adding browser specific CSS, which is generally undesirable but sometimes unavoidable. Below is an example of adding the conditional wrapper div for IE6, which is used primarily for targeting your CSS as well as using different background images between IE6 and > IE6. Also shown is the conditional div for generating the additional markup required for the background images.

Rounded Corners with background-images



Your CSS for IE browsers would be something like:



And that’s just the CSS for IE! You might need something different to get rounded corners with background-images working in Firefox, Safari, Chrome, and Opera.

Rounded Corners using CSS3 border-radius To the rescue came the CSS3 property, border-radius. Border-radius allowed web developers and designers to easily create rounded corners simply by declaring the “border-radius:” property and specifying a value. *The property to be declared actually depends on your browser, and I will get into that later when I show you the code. Currently, the CSS3 border-radius property is supported by recent versions of major browsers such as Firefox (Gecko), Safari (Webkit), Google Chrome (Webkit), and Opera (Presto). However, Internet Explorer versions 6-8 do not support border-radius. For me, the decision on whether to support IE at all, and if so which versions, depends on the project.





Using the border-radius property gives us rounded corners in almost all the popular browsers, while requiring less html mark-up and fewer CSS rules. If you need to support Internet Explorer, you can use the border-radius approach in combination with background-images. Working demo here.


Link|

16 Responses to Rounded Corners With or Without Images

  1. lubin says:

    Outstanding post! I’ve bookmark this site to return later. thanks!

  2. Great articles & Nice a site….

  3. Its helpful article. Congratulations.

  4. Thanks for creating this. I really feel as though I know so much more about the topic than I did before. You should continue this, Im sure most people would agree youve got a gift.

  5. This type of wonderful article! Thank you very much for discussing this blog post!

  6. its superb as your other content : D, appreciate it for putting up.

  7. Issac Maez says:

    This is getting a bit more subjective, but I much prefer the Zune Marketplace. The interface is colorful, has more flair, and some cool features like ‘Mixview’ that let you quickly see related albums, songs, or other users related to what you’re listening to. Clicking on one of those will center on that item, and another set of “neighbors” will come into view, allowing you to navigate around exploring by similar artists, songs, or users. Speaking of users, the Zune “Social” is also great fun, letting you find others with shared tastes and becoming friends with them. You then can listen to a playlist created based on an amalgamation of what all your friends are listening to, which is also enjoyable. Those concerned with privacy will be relieved to know you can prevent the public from seeing your personal listening habits if you so choose.

  8. Breanna Saik says:

    Hm, I am ok with this nevertheless not totally certain, therefore i am gonna research a tad bit more.

  9. Thank you for sharing these nice news with us.

  10. That may seem fine but i am just still not so sure that I like it. Anyhow will look even more into it and decide for myself! :)

  11. O . k ., what a good start but i’m going to look into that a little bit more. Will let you know exactly what else there is.

  12. This page appears to recieve a great deal of visitors. How do you get traffic to it? It gives a nice unique spin on things. I guess having something real or substantial to say is the most important thing.

  13. Elvin Patrie says:

    I got what you mean , thanks for posting .

  14. Great Post. You do a good job. Thanks again

  15. My husband and i have been absolutely lucky when Ervin managed to do his reports from your precious recommendations he received out of the site. It is now and again perplexing just to find yourself giving away tips and hints some others could have been making money from. And now we discover we have you to be grateful to for this. Most of the illustrations you have made, the easy web site menu, the relationships you assist to instill – it’s all amazing, and it’s really assisting our son and our family reckon that that concept is pleasurable, which is rather essential. Thank you for the whole thing!

  16. I and my buddies appeared to be checking the excellent suggestions on your web page and all of a sudden got a terrible feeling I never thanked you for those tips. The young men are actually so very interested to read all of them and already have certainly been using those things. Many thanks for indeed being quite helpful as well as for getting some useful areas most people are really desirous to be informed on. My personal honest regret for not expressing appreciation to you earlier.

Top Posts
Links Tag Archive