Curved borders in HTML/CSS?
Asked by
Link (
327)
June 22nd, 2009
How do Web designers create boxes with curved borders on their Web sites? What is the HTML/CSS code? Thanks in advance.
Observing members:
0
Composing members:
0
7 Answers
The most common method involves one block level element with another block level element inside of it. The “bottom” element has a background image with no vertical repeat for the top left and right corners, and the element on top, which contains the content for the widget, has the bottom left and right. This way, as the box expands vertically, the corners move with it.
You can also do it with CSS and Javascript and several other methods besides images.
When building Tweet My Gaming (have you seen it advertised in the sidebar on Twitter.com? ;p) we actually decided to use the border-radius CSS property for WebKit and Mozilla-based browsers. In our opinion, the site looks totally acceptable in Internet Explorer and Opera (and other browsers that don’t have similar support), and Safari, Chrome and Firefox get a little extra visual reward.
The usage of the CSS properties is a lot like:
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
With the first targeting Safari, Chrome and other modern WebKit-based browsers, and the second targeting Mozilla-based Gecko browsers.
Answer this question
This question is in the General Section. Responses must be helpful and on-topic.