Page 173 - css揭秘
P. 173

$$('.circular').forEach(function(el) {                     JS
                                                      var NS = "http://www.w3.org/2000/svg";
                                                      var xlinkNS = "http://www.w3.org/1999/xlink";
                                                      var svg = document.createElementNS(NS, "svg");
                                                      var circle = document.createElementNS(NS, "path");
                                                      var text = document.createElementNS(NS, "text");
                                                      var textPath = document.createElementNS(NS, "textPath");
                                                      svg.setAttribute("viewBox", "0 0 100 100");

                                                      circle.setAttribute("d", "M0,50 a50,50 0 1,1 0,1z");
                                                      circle.setAttribute("id", "circle");

                                                      textPath.textContent = el.textContent;
                                                      textPath.setAttributeNS(xlinkNS, "xlink:href", "#circle");

                                                      text.appendChild(textPath);
                                                      svg.appendChild(circle);
                                                      svg.appendChild(text);
                                                      el.textContent = '';
                                                      el.appendChild(svg);
                                                  });


                                               试一试 play.csssecrets.io/circular-text




                                                   „ 可缩放矢量图形 SVG
                                                  http://w3.org/TR/SVG                             相关规范








































                  142   第 5 章 字体排印







          ඀ࠡ  JOEC
   168   169   170   171   172   173   174   175   176   177   178