{"id":262,"date":"2011-04-15T09:23:25","date_gmt":"2011-04-15T08:23:25","guid":{"rendered":"http:\/\/www.manuelmarangoni.it\/sir-bit\/?p=262"},"modified":"2016-01-07T17:06:59","modified_gmt":"2016-01-07T16:06:59","slug":"bordi-arrotondati-con-css-o-jquery","status":"publish","type":"post","link":"https:\/\/www.manuelmarangoni.it\/sir-bit\/262\/bordi-arrotondati-con-css-o-jquery\/","title":{"rendered":"Bordi arrotondati con css o jquery"},"content":{"rendered":"<p>I bordi arrotondati sono sempre stati un problema, soprattutto per quanto riguarda <strong>internet explorer<\/strong>, che fino alla versione 8 \u00e8 <strong>privo di supporto<\/strong> per questa propriet\u00e0.<\/p>\n<p>Per gli altri browser \u00e8 piuttosto semplice, si deve utilizzare coi CSS il border-radius, il -moz e il -webkit. Sono paroloni, ma \u00e8 pi\u00f9 semplice di quanto sembri. Andiamo a vedere come.<!--more--><\/p>\n<h2>Bordi arrotondati con css3<\/h2>\n<p>Coi css si pu\u00f2 fare in questo modo:<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n2\r\n3<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"css\" style=\"font-family: monospace;\">border-radius<span style=\"color: #00aa00;\">:<\/span> <span style=\"color: #993333;\">5px<\/span><span style=\"color: #00aa00;\">;<\/span>\r\n-moz-border-radius<span style=\"color: #00aa00;\">:<\/span> <span style=\"color: #993333;\">5px<\/span><span style=\"color: #00aa00;\">;<\/span>\r\n-webkit-border-radius<span style=\"color: #00aa00;\">:<\/span> <span style=\"color: #993333;\">5px<\/span><span style=\"color: #00aa00;\">;<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Sembra una ripetizione, ma usarli tutti e 3 permette di renderlo compatibile con firefox, chrome e safari.<br \/>\nPer avere un aiuto, potete usare <a href=\"http:\/\/border-radius.com\/\" target=\"_blank\">questo sito<\/a> che vi genera il codice in automatico in base ai pixel scelti sull&#8217;angolo.<\/p>\n<div style=\"border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; background-color: #000; color: #fff; padding: 10px; width: 150px; margin: auto;\">Questo div ha i bordi arrotondati di 10pixel<\/div>\n<p>Per il precedente box il css \u00e8 questo<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n2\r\n3\r\n4\r\n5<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"css\" style=\"font-family: monospace;\">border-radius<span style=\"color: #00aa00;\">:<\/span> <span style=\"color: #993333;\">10px<\/span><span style=\"color: #00aa00;\">;<\/span>\r\n-moz-border-radius<span style=\"color: #00aa00;\">:<\/span> <span style=\"color: #993333;\">10px<\/span><span style=\"color: #00aa00;\">;<\/span>\r\n-webkit-border-radius<span style=\"color: #00aa00;\">:<\/span> <span style=\"color: #993333;\">10px<\/span><span style=\"color: #00aa00;\">;<\/span>\r\n<span style=\"color: #000000; font-weight: bold;\">background-color<\/span><span style=\"color: #00aa00;\">:<\/span><span style=\"color: #cc00cc;\">#000<\/span><span style=\"color: #00aa00;\">;<\/span> <span style=\"color: #000000; font-weight: bold;\">color<\/span><span style=\"color: #00aa00;\">:<\/span><span style=\"color: #cc00cc;\">#fff<\/span><span style=\"color: #00aa00;\">;<\/span>\r\n<span style=\"color: #000000; font-weight: bold;\">padding<\/span><span style=\"color: #00aa00;\">:<\/span><span style=\"color: #993333;\">10px<\/span><span style=\"color: #00aa00;\">;<\/span> <span style=\"color: #000000; font-weight: bold;\">width<\/span><span style=\"color: #00aa00;\">:<\/span><span style=\"color: #993333;\">150px<\/span><span style=\"color: #00aa00;\">;<\/span> <span style=\"color: #000000; font-weight: bold;\">margin<\/span><span style=\"color: #00aa00;\">:<\/span><span style=\"color: #993333;\">auto<\/span><span style=\"color: #00aa00;\">;<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Con explorer, per\u00f2, non comparir\u00e0 nessun arrotondamento.<\/p>\n<h2>Bordi arrotondati con Jquery Rounded Corners<\/h2>\n<p>Ci viene in aiuto una libreria <strong>jquery<\/strong>, <a href=\"http:\/\/plugins.jquery.com\/project\/corners\" target=\"_blank\">Rounded Corners<\/a>.<br \/>\nScaricate il pacchetto <a href=\"http:\/\/plugins.jquery.com\/node\/3306\/release\" target=\"_blank\">a questo link<\/a> e inserite il codice per richiamare la libreria<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n2\r\n3<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"html4strict\" style=\"font-family: monospace;\"><span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">script<\/span> <span style=\"color: #000066;\">src<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">\"http:\/\/www.google.com\/jsapi\"<\/span>&gt;&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">script<\/span>&gt;<\/span>\r\n<span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">script<\/span>&gt;<\/span>google.load(\"jquery\", \"1.2.6\")<span style=\"color: #009900;\">&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">script<\/span>&gt;<\/span>\r\n<span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">script<\/span> <span style=\"color: #000066;\">src<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">\"jquery.corners.js\"<\/span>&gt;&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">script<\/span>&gt;<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>La riga 1 e 2 \u00e8 per richiamare jquery da google, se avete il file inseritelo direttamente.<\/p>\n\n<p>Farlo andare \u00e8 piuttosto semplice.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n2\r\n3\r\n4\r\n5\r\n6<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\">&lt;script type=\"text\/javascript\" language=\"javascript\" src=\"\/source\/jquery.corners.min.js\"&gt;&lt;\/script&gt;\r\n<span style=\"color: #339933;\">&lt;<\/span>script type<span style=\"color: #339933;\">=<\/span><span style=\"color: #3366cc;\">\"text\/javascript\"<\/span><span style=\"color: #339933;\">&gt;<\/span>\r\n$<span style=\"color: #009900;\">(<\/span>document<span style=\"color: #009900;\">)<\/span>.<span style=\"color: #660066;\">ready<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #009900;\">{<\/span>\r\n\t$<span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'.corner'<\/span><span style=\"color: #009900;\">)<\/span>.<span style=\"color: #660066;\">corners<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n<span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n<span style=\"color: #339933;\">&lt;\/<\/span>script<span style=\"color: #339933;\">&gt;<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Si richiama la funzione che verr\u00e0 applicata a tutti gli elementi con la classe &#8220;<strong>corner<\/strong>&#8220;. Il div precedente quindi avr\u00e0 questo codice:<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n2\r\n3\r\n4<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"html4strict\" style=\"font-family: monospace;\"><span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">div<\/span> <span style=\"color: #000066;\">class<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">\"corner\"<\/span> <\/span>\r\n<span style=\"color: #009900;\"> <span style=\"color: #000066;\">style<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">\"background-color:#000; color:#fff; padding:10px; width:150px; margin:auto;\"<\/span>&gt;<\/span>\r\nQuesto div ha i bordi arrotondati di 10pixel\r\n<span style=\"color: #009900;\">&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">div<\/span>&gt;<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>E verr\u00e0 mostrato cos\u00ec<br \/>\n<script src=\"\/source\/jquery.corners.js\" type=\"text\/javascript\"><\/script><script type=\"text\/javascript\">\/\/ <![CDATA[\n$(document).ready(function(){ $('.rounded').corners(); });\n\/\/ ]]><\/script><\/p>\n<div class=\"rounded\" style=\"background-color: #000; color: #fff; padding: 10px; width: 150px; margin: auto;\">Questo div funziona con explorer<\/div>\n<p>Per personalizzare i bordi \u00e8 necessario inserire una stringa come <strong>parametro della funzione<\/strong>.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"line_numbers\">\n<pre>1\r\n2\r\n3\r\n4\r\n5<\/pre>\n<\/td>\n<td class=\"code\">\n<pre class=\"javascript\" style=\"font-family: monospace;\"><span style=\"color: #339933;\">&lt;<\/span>script type<span style=\"color: #339933;\">=<\/span><span style=\"color: #3366cc;\">\"text\/javascript\"<\/span><span style=\"color: #339933;\">&gt;<\/span>\r\n$<span style=\"color: #009900;\">(<\/span>document<span style=\"color: #009900;\">)<\/span>.<span style=\"color: #660066;\">ready<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #009900;\">{<\/span>\r\n\t$<span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'.rounded'<\/span><span style=\"color: #009900;\">)<\/span>.<span style=\"color: #660066;\">corners<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'10px left'<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n<span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n<span style=\"color: #339933;\">&lt;\/<\/span>script<span style=\"color: #339933;\">&gt;<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Cos\u00ec far\u00e0 un bordo di 10px solo a sinistra. Altri parametri di posizionamento sono i seguenti:<br \/>\n<strong>top<br \/>\nright<br \/>\nbottom<br \/>\nleft<br \/>\ntop-left<br \/>\ntop-right<br \/>\nbottom-left<br \/>\nbottom-right<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I bordi arrotondati sono sempre stati un problema, soprattutto per quanto riguarda internet explorer, che fino alla versione 8 \u00e8 privo di supporto per questa propriet\u00e0. Per gli altri browser \u00e8 piuttosto semplice, si deve utilizzare coi CSS il border-radius, il -moz e il -webkit. Sono paroloni, ma \u00e8 pi\u00f9 semplice di quanto sembri. Andiamo [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[80],"tags":[28,24,11],"class_list":["post-262","post","type-post","status-publish","format-standard","hentry","category-javascript-e-derivati","tag-css","tag-html","tag-jquery","cat-80-id"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.manuelmarangoni.it\/sir-bit\/wp-json\/wp\/v2\/posts\/262"}],"collection":[{"href":"https:\/\/www.manuelmarangoni.it\/sir-bit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.manuelmarangoni.it\/sir-bit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.manuelmarangoni.it\/sir-bit\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.manuelmarangoni.it\/sir-bit\/wp-json\/wp\/v2\/comments?post=262"}],"version-history":[{"count":29,"href":"https:\/\/www.manuelmarangoni.it\/sir-bit\/wp-json\/wp\/v2\/posts\/262\/revisions"}],"predecessor-version":[{"id":2155,"href":"https:\/\/www.manuelmarangoni.it\/sir-bit\/wp-json\/wp\/v2\/posts\/262\/revisions\/2155"}],"wp:attachment":[{"href":"https:\/\/www.manuelmarangoni.it\/sir-bit\/wp-json\/wp\/v2\/media?parent=262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.manuelmarangoni.it\/sir-bit\/wp-json\/wp\/v2\/categories?post=262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.manuelmarangoni.it\/sir-bit\/wp-json\/wp\/v2\/tags?post=262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}