pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <i id='C2UHu'><tr id='C2UHu'><dt id='C2UHu'><q id='C2UHu'><span id='C2UHu'><b id='C2UHu'><form id='C2UHu'><ins id='C2UHu'></ins><ul id='C2UHu'></ul><sub id='C2UHu'></sub></form><legend id='C2UHu'></legend><bdo id='C2UHu'><pre id='C2UHu'><center id='C2UHu'></center></pre></bdo></b><th id='C2UHu'></th></span></q></dt></tr></i><div class="t7v8x3l" id='C2UHu'><tfoot id='C2UHu'></tfoot><dl id='C2UHu'><fieldset id='C2UHu'></fieldset></dl></div>
  • <legend id='C2UHu'><style id='C2UHu'><dir id='C2UHu'><q id='C2UHu'></q></dir></style></legend>
    • <bdo id='C2UHu'></bdo><ul id='C2UHu'></ul>

  • <small id='C2UHu'></small><noframes id='C2UHu'>

    1. <tfoot id='C2UHu'></tfoot>

        Chrome 和 Firefox 中的 SVG 文本對(duì)齊不一致

        Inconsistent SVG text alignment in Chrome and Firefox(Chrome 和 Firefox 中的 SVG 文本對(duì)齊不一致)
      1. <tfoot id='WKrJ9'></tfoot>
          <bdo id='WKrJ9'></bdo><ul id='WKrJ9'></ul>

                    <tbody id='WKrJ9'></tbody>

                  <i id='WKrJ9'><tr id='WKrJ9'><dt id='WKrJ9'><q id='WKrJ9'><span id='WKrJ9'><b id='WKrJ9'><form id='WKrJ9'><ins id='WKrJ9'></ins><ul id='WKrJ9'></ul><sub id='WKrJ9'></sub></form><legend id='WKrJ9'></legend><bdo id='WKrJ9'><pre id='WKrJ9'><center id='WKrJ9'></center></pre></bdo></b><th id='WKrJ9'></th></span></q></dt></tr></i><div class="b8ofbag" id='WKrJ9'><tfoot id='WKrJ9'></tfoot><dl id='WKrJ9'><fieldset id='WKrJ9'></fieldset></dl></div>

                  <legend id='WKrJ9'><style id='WKrJ9'><dir id='WKrJ9'><q id='WKrJ9'></q></dir></style></legend>

                  <small id='WKrJ9'></small><noframes id='WKrJ9'>

                  本文介紹了Chrome 和 Firefox 中的 SVG 文本對(duì)齊不一致的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我在 Leaflet.js 地圖上繪制 SVG 標(biāo)記圖標(biāo).圖標(biāo)代表氣象站,它們會(huì)根據(jù)風(fēng)向旋轉(zhuǎn),并以疊加的形式顯示平均風(fēng)速.

                  I'm drawing SVG marker icons on a Leaflet.js map. The icons represent weather stations and they are rotated according to the wind direction and show the average wind speed as an overlay.

                  我已經(jīng)能夠讓它在 Chrome 中按需要工作,但在 Firefox 中文本位置已關(guān)閉.

                  I have been able to get this to work as desired in Chrome but the text position is off in Firefox.

                  左邊是 Chrome (55.0.2883.95),右邊是 Firefox (50.0.1).

                  這是我正在使用的自定義 Leaflet.Icon 類:

                  This is the custom Leaflet.Icon class I'm using:

                  window.RemoteWind = window.RemoteWind || {};
                  
                  // This uses Chroma.js to build a color scale which is used for wind speed.
                  // http://gka.github.io/chroma.js
                  RemoteWind.color_scale = chroma.scale([
                    'lightblue',
                    'green',
                    'red',
                    'purple'
                  ])
                  .mode('hsl') // the blending mode
                  .domain([0, 7, 15, 25]); // the distinct steps for each.
                  
                  RemoteWind.VectorIcon = L.Icon.extend({
                    options: {
                      height: 26,
                      width: 26,
                      stroke: 'white',
                      strokeWidth: 2,
                      circle: {
                        cx: 13,
                        cy: 13,
                        r: 13
                      }
                    },
                    _createSVG: function(){
                      var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
                      svg.setAttributeNS(null, 'version', '1.1')
                      svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
                      svg.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
                      svg.setAttribute('height', this.options.height);
                      svg.setAttribute('width',  this.options.width);
                      return svg;
                    }
                  });
                  
                  /*
                  * Vector based icon for a station
                  */
                  RemoteWind.StationIcon = RemoteWind.VectorIcon.extend({
                    options: {
                      className: 'leaflet-station-icon active',
                      speed: 0,
                      direction: 0,
                      path: {
                        d: "M26,19c0-2.2-0.6-4.4-1.6-6.2C22.2,8.8,13,0,13,0S3.8,8.7,1.6,12.8c-1,1.8-1.6,4-1.6,6.2c0,7.2,5.8,13,13,13 S26,26.2,26,19z"
                      }
                    },
                    createIcon: function (oldIcon) {
                      var div = (oldIcon && oldIcon.tagName === 'DIV') ? oldIcon : document.createElement('div'),
                      svg = this._createSVG(),
                      g = document.createElementNS('http://www.w3.org/2000/svg', 'g'),
                      txt_g = document.createElementNS('http://www.w3.org/2000/svg', 'g'),
                      options = this.options,
                      path,
                      txt;
                  
                      g.setAttributeNS(null, "transform", "translate(0,-6)");
                  
                      path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
                      path.setAttributeNS(null, 'd', "M26,19c0-2.2-0.6-4.4-1.6-6.2C22.2,8.8,13,0,13,0S3.8,8.7,1.6,12.8c-1,1.8-1.6,4-1.6,6.2c0,7.2,5.8,13,13,13 S26,26.2,26,19z");
                      path.setAttributeNS(null, 'stroke', this.options.stroke);
                      path.setAttributeNS(null, 'stroke-width', this.options.strokeWidth);
                      path.setAttributeNS(null, 'fill', RemoteWind.color_scale(options.speed).name() );
                      path.setAttributeNS(null, 'transform', 'rotate(% 13 19)'.replace('%', options.direction));
                  
                      txt = document.createElementNS('http://www.w3.org/2000/svg', 'text');
                      txt.innerHTML = Math.round(options.speed).toString();
                      txt.setAttributeNS(null, 'fill', 'white');
                      txt.setAttributeNS(null, 'x', this.options.height / 2);
                      txt.setAttributeNS(null, 'y', this.options.width / 2);
                      txt.setAttributeNS(null, 'text-anchor', 'middle');
                      txt.setAttributeNS(null, 'alignment-baseline', 'central');
                  
                      g.appendChild(path);
                      txt_g.appendChild(txt);
                      svg.appendChild(g);
                      svg.appendChild(txt_g);
                      div.appendChild(svg);
                      this._setIconStyles(div, 'icon');
                      return div;
                    },
                  
                    createShadow: function () {
                      return null;
                    }
                  });
                  
                  RemoteWind.stationIcon = function (options) {
                    return new RemoteWind.StationIcon(options);
                  };
                  

                  我通過設(shè)置 text-anchor="middle"alignment-baseline="central" 加上 x 來定位文本和 y 坐標(biāo).

                  I'm positioning the text by setting text-anchor="middle" and alignment-baseline="central" plus the x and y coordinates.

                  這是添加標(biāo)記時(shí)在 DOM 中創(chuàng)建的 HTML:

                  This is the HTML created in the DOM when the marker is added:

                  <div class="leaflet-marker-icon leaflet-station-icon active leaflet-zoom-animated leaflet-interactive" title="?re strand | 2(3) m/s" tabindex="0" style="transform: translate3d(-367px, 85px, 0px); z-index: 85; outline: none;">
                    <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="26" width="26">
                      <g transform="translate(0,-6)">
                        <path d="M26,19c0-2.2-0.6-4.4-1.6-6.2C22.2,8.8,13,0,13,0S3.8,8.7,1.6,12.8c-1,1.8-1.6,4-1.6,6.2c0,7.2,5.8,13,13,13 S26,26.2,26,19z" stroke="white" stroke-width="2" fill="#64e0d2" transform="rotate(338 13 19)"></path>
                      </g>
                      <g>
                        <text fill="white" x="13" y="13" text-anchor="middle" alignment-baseline="central">2</text>
                      </g>
                    </svg>
                  </div>
                  

                  為什么 firefox 不能正確定位文本?

                  Why is firefox not positioning the text correctly?

                  推薦答案

                  Firefox 目前不支持 對(duì)齊基線.它確實(shí)支持 dominant-baseline,這對(duì)你的用例來說幾乎是一樣的.

                  Firefox does not currently support alignment-baseline. It does support dominant-baseline, which amounts to pretty much the same thing for your use case.

                  這篇關(guān)于Chrome 和 Firefox 中的 SVG 文本對(duì)齊不一致的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個(gè)多邊形點(diǎn)是否在傳單中的另一個(gè)內(nèi)部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標(biāo)記群集圖標(biāo)顏色,繼承其余默認(rèn) CSS 屬性)
                  Trigger click on leaflet marker(觸發(fā)點(diǎn)擊傳單標(biāo)記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認(rèn)加載磁貼顏色?)
                  Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側(cè)邊欄)
                    <bdo id='JusiR'></bdo><ul id='JusiR'></ul>
                      <tfoot id='JusiR'></tfoot>

                          <tbody id='JusiR'></tbody>

                          <i id='JusiR'><tr id='JusiR'><dt id='JusiR'><q id='JusiR'><span id='JusiR'><b id='JusiR'><form id='JusiR'><ins id='JusiR'></ins><ul id='JusiR'></ul><sub id='JusiR'></sub></form><legend id='JusiR'></legend><bdo id='JusiR'><pre id='JusiR'><center id='JusiR'></center></pre></bdo></b><th id='JusiR'></th></span></q></dt></tr></i><div class="ggu3tof" id='JusiR'><tfoot id='JusiR'></tfoot><dl id='JusiR'><fieldset id='JusiR'></fieldset></dl></div>
                          <legend id='JusiR'><style id='JusiR'><dir id='JusiR'><q id='JusiR'></q></dir></style></legend>

                            <small id='JusiR'></small><noframes id='JusiR'>

                            主站蜘蛛池模板: 工业洗衣机_工业洗涤设备_上海力净工业洗衣机厂家-洗涤设备首页 bkzzy在职研究生网 - 在职研究生招生信息咨询平台 | 固诺家居-全屋定制十大品牌_整体衣柜木门橱柜招商加盟 | 通辽信息港 - 免费发布房产、招聘、求职、二手、商铺等信息 www.tlxxg.net | 周口市风机厂,周鼓风机,河南省周口市风机厂 | 贝朗斯动力商城(BRCPOWER.COM) - 买叉车蓄电池上贝朗斯商城,价格更超值,品质有保障! | 合肥钣金加工-安徽激光切割加工-机箱机柜加工厂家-合肥通快 | 仿古建筑设计-仿古建筑施工-仿古建筑公司-汉匠古建筑设计院 | 海峰资讯 - 专注装饰公司营销型网站建设和网络营销培训 | 济南网站建设_济南网站制作_济南网站设计_济南网站建设公司_富库网络旗下模易宝_模板建站 | 天津市能谱科技有限公司-专业的红外光谱仪_红外测油仪_紫外测油仪_红外制样附件_傅里叶红外光谱技术生产服务厂商 | 行业分析:提及郑州火车站附近真有 特殊按摩 ?2025实地踩坑指南 新手如何避坑不踩雷 | 升降机-高空作业车租赁-蜘蛛车-曲臂式伸缩臂剪叉式液压升降平台-脚手架-【普雷斯特公司厂家】 | 东莞韩创-专业绝缘骨架|马达塑胶零件|塑胶电机配件|塑封电机骨架厂家 | 餐饮小吃技术培训-火锅串串香培训「何小胖培训」_成都点石成金[官网] | 自动气象站_农业气象站_超声波气象站_防爆气象站-山东万象环境科技有限公司 | 塑料薄膜_PP薄膜_聚乙烯薄膜-常州市鑫美新材料包装厂 | 吹塑加工_大型吹塑加工_滚塑代加工-莱力奇吹塑加工有限公司 | 考勤系统_考勤管理系统_网络考勤软件_政企|集团|工厂复杂考勤工时统计排班管理系统_天时考勤 | 赛默飞Thermo veritiproPCR仪|ProFlex3 x 32PCR系统|Countess3细胞计数仪|371|3111二氧化碳培养箱|Mirco17R|Mirco21R离心机|仟诺生物 | 对辊式破碎机-对辊制砂机-双辊-双齿辊破碎机-巩义市裕顺机械制造有限公司 | 上海橡胶接头_弹簧减震器_金属软接头厂家-上海淞江集团 | 一体化污水处理设备,一体化污水设备厂家-宜兴市福源水处理设备有限公司 | 中空玻璃生产线,玻璃加工设备,全自动封胶线,铝条折弯机,双组份打胶机,丁基胶/卧式/立式全自动涂布机,玻璃设备-山东昌盛数控设备有限公司 | 不锈钢酒柜|恒温酒柜|酒柜定制|酒窖定制-上海啸瑞实业有限公司 | 河南彩印编织袋,郑州饲料编织袋定制,肥料编织袋加工厂-盛军塑业 河南凯邦机械制造有限公司 | 垃圾压缩设备_垃圾处理设备_智能移动式垃圾压缩设备--山东明莱环保设备有限公司 | 不锈钢螺丝 - 六角螺丝厂家 - 不锈钢紧固件 - 万千紧固件--紧固件一站式采购 | 柴油发电机组_柴油发电机_发电机组价格-江苏凯晨电力设备有限公司 | 船用泵,船用离心泵,船用喷射泵,泰州隆华船舶设备有限公司 | 桁架机器人_桁架机械手_上下料机械手_数控车床机械手-苏州清智科技装备制造有限公司 | 自动检重秤-动态称重机-重量分选秤-苏州金钻称重设备系统开发有限公司 | 产业规划_产业园区规划-产业投资选址及规划招商托管一体化服务商-中机院产业园区规划网 | 东莞工厂厂房装修_无尘车间施工_钢结构工程安装-广东集景建筑装饰设计工程有限公司 | 分光色差仪,测色仪,反透射灯箱,爱色丽分光光度仪,美能达色差仪维修_苏州欣美和仪器有限公司 | 冲锋衣滑雪服厂家-冲锋衣定制工厂-滑雪服加工厂-广东睿牛户外(S-GERT) | 辽宁资质代办_辽宁建筑资质办理_辽宁建筑资质延期升级_辽宁中杭资质代办 | 钢衬四氟管道_钢衬四氟直管_聚四氟乙烯衬里管件_聚四氟乙烯衬里管道-沧州汇霖管道科技有限公司 | 蓝莓施肥机,智能施肥机,自动施肥机,水肥一体化项目,水肥一体机厂家,小型施肥机,圣大节水,滴灌施工方案,山东圣大节水科技有限公司官网17864474793 | 电动车头盔厂家_赠品头盔_安全帽批发_山东摩托车头盔—临沂承福头盔 | 煤棒机_增碳剂颗粒机_活性炭颗粒机_木炭粉成型机-巩义市老城振华机械厂 | 长沙网站建设制作「网站优化推广」-网页设计公司-速马科技官网 |