{"id":482,"date":"2009-04-24T13:46:58","date_gmt":"2009-04-24T13:46:58","guid":{"rendered":"https:\/\/surfrock66.com\/blog\/?p=482"},"modified":"2010-01-22T14:58:32","modified_gmt":"2010-01-22T19:58:32","slug":"css-only-rounded-shadowed-transparent-corners","status":"publish","type":"post","link":"https:\/\/surfrock66.com\/?p=482","title":{"rendered":"CSS-Only Rounded, Shadowed, Transparent Corners"},"content":{"rendered":"<p>I've been super frustrated on a web project I've been on where I've wanted CSS-only (no slow-ass JSON solutions) rounded corners with transparent backgrounds and and drop shadows.  I originally tried a 3 image solution with transparent backgrounds, but it didn't work well and the middle image showed up behind the top and bottom images.  I tried just making the backgrounds of the png's match the css background, and I discovered the OSX Safari png gamma correction bug.  I hate GIF's and JPEG's as much as I can avoid them, so I decided to just rewrite the solution from scratch, which isn't that hard.<\/p><br \/><p>The real reason I am writing this is because 90% of the time I want to do something online I just search for code to do something and use the first result as a template.  It took me like 30 tries and I still found nothing decent, so I decided to just do it myself from scratch, and maybe someone else can use it.<\/p><br \/><p>This is a 9 image solution made in 3 horizontal sections: a header, a center block, and a footer.  Yea, it's a ton of nested divs, but it validates, uses no overlap, works on all browsershots I have tested, and can be used with very small pngs.  First of all, <a href=\"\/sub_pages\/box\/\">here's a sample of the result.<\/a> Here's the images, their titles, and their dimensions, all of which can be modified:<\/p><ul>\r\n <li>Top Left Corner, 15px x 15px, tlc.png <img style=\"border: 1px solid #FFFFFF;\" src=\"\/sub_pages\/box\/tlc.png\" alt=\"tlc\" \/><\/li>\r\n <li>Top Border, 1px x 15px, tb.png <img style=\"border: 1px solid #FFFFFF;\" src=\"\/sub_pages\/box\/tb.png\" alt=\"tb\" \/><\/li>\r\n <li>Top Right Corner, 15px x 15px, trc.png <img style=\"border: 1px solid #FFFFFF;\" src=\"\/sub_pages\/box\/trc.png\" alt=\"trc\" \/><\/li>\r\n <li>Left Border, 15px x 1px, l.png <img style=\"border: 1px solid #FFFFFF;\" src=\"\/sub_pages\/box\/l.png\" alt=\"l\" \/><\/li>\r\n <li>Center, 1px x 1px, c.png <img style=\"border: 1px solid #FFFFFF;\" src=\"\/sub_pages\/box\/c.png\" alt=\"c\" \/><\/li>\r\n <li>Right Border, 15px x 1px, r.png <img style=\"border: 1px solid #FFFFFF;\" src=\"\/sub_pages\/box\/r.png\" alt=\"r\" \/><\/li>\r\n <li>Bottom Left Corner, 15px x 15px, blc.png <img style=\"border: 1px solid #FFFFFF;\" src=\"\/sub_pages\/box\/blc.png\" alt=\"blc\" \/><\/li>\r\n <li>Bottom Border, 1px x 15px, bb.png <img style=\"border: 1px solid #FFFFFF;\" src=\"\/sub_pages\/box\/bb.png\" alt=\"bb\" \/><\/li>\r\n <li>Bottom Right Corner, 15px x 15px, brc.png <img style=\"border: 1px solid #FFFFFF;\" src=\"\/sub_pages\/box\/brc.png\" alt=\"brc\" \/><\/li>\r\n<\/ul><br \/><p>The html for this box is as follows:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;!DOCTYPE html PUBLIC &quot;-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN&quot; &quot;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd&quot;&gt;\r\n&lt;html xmlns=&quot;http:\/\/www.w3.org\/1999\/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;\r\n &lt;head&gt;\r\n  &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text\/css&quot; media=&quot;screen&quot; title=&quot;no title&quot; charset=&quot;utf-8&quot;\/&gt;\r\n &lt;\/head&gt;\r\n &lt;body&gt;\r\n  &lt;div id=&quot;box&quot;&gt;\r\n   &lt;div id=&quot;tlc&quot;&gt;&lt;div id=&quot;trc&quot;&gt;&lt;div id=&quot;tb&quot;&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;\r\n   &lt;div id=&quot;lb&quot;&gt;&lt;div id=&quot;rb&quot;&gt;&lt;div id=&quot;c&quot;&gt;\r\n    &lt;p&gt;Holy Crap, content galore!&lt;\/p&gt;\r\n   &lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;\r\n   &lt;div id=&quot;blc&quot;&gt;&lt;div id=&quot;brc&quot;&gt;&lt;div id=&quot;bb&quot;&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;\r\n  &lt;\/div&gt;\r\n &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>View the CSS for this technique <a href=\"\/sub_pages\/box\/style.css\">here.<\/a>  Here's how this all breaks down in the box:<\/p><br \/><img src=\"\/sub_pages\/box\/Breakdown.png\" width=\"100%\" alt=\"Breakdown\" \/>\r\n<p>Here's the css required to make this happen, using the variables in the above image:<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">#box {\r\n  text-align: left;\r\n  position: relative;\r\n  margin: 0 auto;\r\n  padding: 0;\r\n  width: $g;\r\n}\r\n#box #c {\r\n  background: transparent url('c.png') repeat center center;\r\n  margin: 0 $e 0 $f;\r\n}\r\n#box #tlc {\r\n  height: $c;\r\n  background: transparent url('tlc.png') no-repeat top left;\r\n}\r\n#box #trc {\r\n  height: $c;\r\n  background: transparent url('trc.png') no-repeat top right;\r\n}\r\n#box #blc {\r\n  height: $d;\r\n  background: transparent url('blc.png') no-repeat bottom left;\r\n}\r\n#box #brc {\r\n  height: $d;\r\n  background: transparent url('brc.png') no-repeat bottom right;\r\n}\r\n#box #tb {\r\n  height: $c;\r\n  margin: 0 $a 0 $b;\r\n  background: transparent url('tb.png') repeat-x top center;\r\n}\r\n#box #bb {\r\n  height: $d;\r\n  margin: 0 $a 0 $b;\r\n  background: transparent url('bb.png') repeat-x bottom center;\r\n}\r\n#box #rb {\r\n  background: transparent url('r.png') repeat-y center right;\r\n}\r\n#box #lb {\r\n  background: transparent url('l.png') repeat-y center left;\r\n}\r\np {\r\n  margin: 0 auto;\r\n  padding: 0;\r\n}\r\n<\/pre>\n<p>It should be very flexible; if you need to you can make the borders bigger or smaller, you can even use different widths for the bottom corners if you must.  I thought about toying with another master-div that was on a higher z-index plane so your content could dip into the header\/footer, but I decided against it because I don't have time.  I hope this is useful, it shouldn't be so complicated but there were no decent guides online.<\/p>\r\n\n","protected":false},"excerpt":{"rendered":"<p>&lt;!DOCTYPE html PUBLIC &quot;-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN&quot; &quot;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd&quot;&gt; &lt;html xmlns=&quot;http:\/\/www.w3.org\/1999\/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt; &lt;head&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; type=&quot;text\/css&quot; media=&quot;screen&quot; title=&quot;no title&quot; charset=&quot;utf-8&quot;\/&gt; &lt;\/head&gt; &lt;body&gt; &lt;div id=&quot;box&quot;&gt; &lt;div id=&quot;tlc&quot;&gt;&lt;div id=&quot;trc&quot;&gt;&lt;div id=&quot;tb&quot;&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt; &lt;div id=&quot;lb&quot;&gt;&lt;div id=&quot;rb&quot;&gt;&lt;div id=&quot;c&quot;&gt; &lt;p&gt;Holy Crap, content galore!&lt;\/p&gt; &lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt; &lt;div id=&quot;blc&quot;&gt;&lt;div id=&quot;brc&quot;&gt;&lt;div id=&quot;bb&quot;&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt; &lt;\/div&gt; &lt;\/body&gt; &lt;\/html&gt; #box { text-align: left; position: relative; margin: 0 auto; padding: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,3],"tags":[],"class_list":["post-482","post","type-post","status-publish","format-standard","hentry","category-geek","category-projects"],"_links":{"self":[{"href":"https:\/\/surfrock66.com\/index.php?rest_route=\/wp\/v2\/posts\/482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/surfrock66.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/surfrock66.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/surfrock66.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/surfrock66.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=482"}],"version-history":[{"count":41,"href":"https:\/\/surfrock66.com\/index.php?rest_route=\/wp\/v2\/posts\/482\/revisions"}],"predecessor-version":[{"id":978,"href":"https:\/\/surfrock66.com\/index.php?rest_route=\/wp\/v2\/posts\/482\/revisions\/978"}],"wp:attachment":[{"href":"https:\/\/surfrock66.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/surfrock66.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/surfrock66.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}