{"id":4640,"date":"2017-10-10T04:49:01","date_gmt":"2017-10-10T04:49:01","guid":{"rendered":"http:\/\/a1webdesignteam.com\/blog\/?p=4640"},"modified":"2017-10-10T04:49:01","modified_gmt":"2017-10-10T04:49:01","slug":"rounded-corners-in-css","status":"publish","type":"post","link":"https:\/\/a1webdesignteam.com\/blog\/rounded-corners-in-css\/","title":{"rendered":"Rounded Corners in CSS"},"content":{"rendered":"<header><strong>Rounded corners<\/strong> used to be the stuff of constricting solid background images or, for flexible boxes, numerous background images, one per-corner, slapped on multiple nested <code>div<\/code>elements. Argh, ugly. Well, not any longer. Now, with simple CSS, you can lavish your designs with more curves than Marilyn Monroe.<\/p>\n<\/header>\n<section>\n<h2>Border radius?<\/h2>\n<p>Yeah. Border radius. Fear not, though \u2014 you don\u2019t have to have borders. The <a class=\"acode\" href=\"http:\/\/www.htmldog.com\/references\/css\/properties\/border-radius\/\"><code>border-radius<\/code><\/a> property can be used to add a corner to each corner of a box.<\/p>\n<pre class=\" language-css\"><code class=\" language-css\">\r\n<span class=\"token selector\">#marilyn<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token property\">background<\/span><span class=\"token punctuation\">:<\/span> #fff<span class=\"token punctuation\">;<\/span>\r\n    <span class=\"token property\">width<\/span><span class=\"token punctuation\">:<\/span> 100px<span class=\"token punctuation\">;<\/span>\r\n    <span class=\"token property\">height<\/span><span class=\"token punctuation\">:<\/span> 100px<span class=\"token punctuation\">;<\/span>\r\n    <strong><span class=\"token property\">border-radius<\/span><span class=\"token punctuation\">:<\/span> 20px<span class=\"token punctuation\">;<\/span><\/strong>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<p>And there you have it. Rounded corners, see? Well, you will if you\u2019ve got a sensible browser (see note below).<\/p>\n<figure class=\"note shot\">\n<div><img loading=\"lazy\" src=\"http:\/\/www.htmldog.com\/figures\/border-radius.png\" width=\"140\" height=\"140\" \/><\/div><figcaption>Corners are cut around the corresponding quarters of a circle (or ellipse) with the specified radius.<\/figcaption><\/figure>\n<p>Of course, if you <em>do<\/em> want a border\u2026<\/p>\n<pre class=\" language-css\"><code class=\" language-css\">\r\n<span class=\"token selector\">#ok_a_border_then<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token property\">border<\/span><span class=\"token punctuation\">:<\/span> 5px solid #8b2<span class=\"token punctuation\">;<\/span>\r\n    <span class=\"token property\">width<\/span><span class=\"token punctuation\">:<\/span> 100px<span class=\"token punctuation\">;<\/span>\r\n    <span class=\"token property\">height<\/span><span class=\"token punctuation\">:<\/span> 100px<span class=\"token punctuation\">;<\/span>\r\n    <strong><span class=\"token property\">border-radius<\/span><span class=\"token punctuation\">:<\/span> 5px<span class=\"token punctuation\">;<\/span><\/strong>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<section>\n<h2>Multiple values<\/h2>\n<p><a class=\"acode\" href=\"http:\/\/www.htmldog.com\/references\/css\/properties\/border-top-left-radius\/\"><code>border-top-left-radius<\/code><\/a>, <a class=\"acode\" href=\"http:\/\/www.htmldog.com\/references\/css\/properties\/border-top-right-radius\/\"><code>border-top-right-radius<\/code><\/a>, <a class=\"acode\" href=\"http:\/\/www.htmldog.com\/references\/css\/properties\/border-bottom-right-radius\/\"><code>border-bottom-right-radius<\/code><\/a>, and <a class=\"acode\" href=\"http:\/\/www.htmldog.com\/references\/css\/properties\/border-bottom-left-radius\/\"><code>border-bottom-left-radius<\/code><\/a> can also be used to target specific corners.<\/p>\n<p>Ever so slightly less horribly wordy, you can also define all corner radii (what a great word) individually with a space-separated list of values, working clockwise from top-left, just like other shorthand properties:<\/p>\n<pre class=\" language-css\"><code class=\" language-css\">\r\n<span class=\"token selector\">#monroe<\/span> <span class=\"token punctuation\">{<\/span>\r\n    <span class=\"token property\">background<\/span><span class=\"token punctuation\">:<\/span> #fff<span class=\"token punctuation\">;<\/span>\r\n    <span class=\"token property\">width<\/span><span class=\"token punctuation\">:<\/span> 100px<span class=\"token punctuation\">;<\/span>\r\n    <span class=\"token property\">height<\/span><span class=\"token punctuation\">:<\/span> 100px<span class=\"token punctuation\">;<\/span>\r\n    <strong><span class=\"token property\">border-radius<\/span><span class=\"token punctuation\">:<\/span> 6px 12px 18px 24px<span class=\"token punctuation\">;<\/span><\/strong>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<figure class=\"note shot\">\n<div><img loading=\"lazy\" src=\"http:\/\/www.htmldog.com\/figures\/border-radius_multiple.png\" width=\"140\" height=\"140\" \/><\/div><figcaption>Multiple-value border-radius.<\/figcaption><\/figure>\n<aside class=\"foodC\">\n<div id=\"bsap_1305864\" class=\"bsap bsap_1305864\" data-serve=\"CVADE23N\">Curvy.<\/div>\n<\/aside>\n<p>By using two values instead of four you target top-left and bottom-right with the first length (or percentage) and top-right + bottom-left with the second. Three values? Top-left, then top-right + bottom-left, then bottom-right. Smashing.<\/p>\n<aside class=\"note warning\">Gah! There just had to be browser issues, didn\u2019t there? Damn you, browsers.<\/p>\n<p>Internet Explorer versions 8 and below don\u2019t support <a class=\"acode\" href=\"http:\/\/www.htmldog.com\/references\/css\/properties\/border-radius\/\"><code>border-radius<\/code><\/a>. The only way you can deal with this is either to make do with a design in those browsers that doesn\u2019t have rounded corners (most people can live with that), or revert to the old background images.<\/p>\n<\/aside>\n<aside class=\"note i\">You might also stumble across similar proprietary properties, such as <code>-webkit-border-radius<\/code> and <code>-moz-border-radius<\/code> which are for older, barely-used versions of Safari and Firefox respectively. Our carefully worded professional advice? Screw \u2018em.<\/p>\n<\/aside>\n<h2>Ellipses<\/h2>\n<p>Are circles a bit too square for you? You can specify different horizontal and vertical radiiii by splitting values with a \u201c\/\u201d.<\/p>\n<pre class=\" language-css\"><code class=\" language-css\">\r\n<span class=\"token selector\">#nanoo<\/span> <span class=\"token punctuation\">{<\/span>\r\n        <span class=\"token property\">background<\/span><span class=\"token punctuation\">:<\/span> #fff<span class=\"token punctuation\">;<\/span>\r\n        <span class=\"token property\">width<\/span><span class=\"token punctuation\">:<\/span> 100px<span class=\"token punctuation\">;<\/span>\r\n        <span class=\"token property\">height<\/span><span class=\"token punctuation\">:<\/span> 150px<span class=\"token punctuation\">;<\/span>\r\n        <strong><span class=\"token property\">border-radius<\/span><span class=\"token punctuation\">:<\/span> 50px\/100px<span class=\"token punctuation\">;<\/span><\/strong>\r\n        <span class=\"token property\">border-bottom-left-radius<\/span><span class=\"token punctuation\">:<\/span> 50px<span class=\"token punctuation\">;<\/span>\r\n        <span class=\"token property\">border-bottom-right-radius<\/span><span class=\"token punctuation\">:<\/span> 50px<span class=\"token punctuation\">;<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<\/code><\/pre>\n<figure class=\"note shot\">\n<div><img loading=\"lazy\" src=\"http:\/\/www.htmldog.com\/figures\/border-radius_nanoo.png\" width=\"140\" height=\"190\" \/><\/div><figcaption>Nanoo.<\/figcaption><\/figure>\n<\/section>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>Rounded corners used to be the stuff of constricting solid background images or, for flexible boxes, numerous background images, one per-corner, slapped on multiple nested divelements. Argh, ugly. Well, not any longer. Now, with simple CSS, you can lavish your designs with more curves than Marilyn Monroe. Border radius? Yeah. Border radius. Fear not, though [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4641,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0},"categories":[5],"tags":[51],"_links":{"self":[{"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/posts\/4640"}],"collection":[{"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/comments?post=4640"}],"version-history":[{"count":0,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/posts\/4640\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/media\/4641"}],"wp:attachment":[{"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/media?parent=4640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/categories?post=4640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/tags?post=4640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}