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'>

                            主站蜘蛛池模板: 订做不锈钢_不锈钢定做加工厂_不锈钢非标定制-重庆侨峰金属加工厂 | 青岛美佳乐清洁工程有限公司|青岛油烟管道清洗|酒店|企事业单位|学校工厂厨房|青岛油烟管道清洗 插针变压器-家用电器变压器-工业空调变压器-CD型电抗器-余姚市中驰电器有限公司 | 引领中高档酒店加盟_含舍·美素酒店品牌官网 | 郑州外墙清洗_郑州玻璃幕墙清洗_郑州开荒保洁-河南三恒清洗服务有限公司 | 深圳公司注册-工商注册代理-注册公司流程和费用_护航财税 | 耐磨陶瓷管道_除渣器厂家-淄博浩瀚陶瓷科技有限公司 | 铝镁锰板_铝镁锰合金板_铝镁锰板厂家_铝镁锰金属屋面板_安徽建科 | 专业生产动态配料系统_饲料配料系统_化肥配料系统等配料系统-郑州鑫晟重工机械有限公司 | 电气控制系统集成商-PLC控制柜变频控制柜-非标自动化定制-电气控制柜成套-NIDEC CT变频器-威肯自动化控制 | 沈阳真空机_沈阳真空包装机_沈阳大米真空包装机-沈阳海鹞真空包装机械有限公司 | 搜木网 - 木业全产业链交易平台,免费搜货、低价买货! | 压力喷雾干燥机,喷雾干燥设备,柱塞隔膜泵-无锡市闻华干燥设备有限公司 | 电动车头盔厂家_赠品头盔_安全帽批发_山东摩托车头盔—临沂承福头盔 | 【电子厂招聘_普工招工网_工厂招聘信息平台】-工立方打工网 | 水厂污泥地磅|污泥处理地磅厂家|地磅无人值守称重系统升级改造|地磅自动称重系统维修-河南成辉电子科技有限公司 | 工程管道/塑料管材/pvc排水管/ppr给水管/pe双壁波纹管等品牌管材批发厂家-河南洁尔康建材 | 莱州网络公司|莱州网站建设|莱州网站优化|莱州阿里巴巴-莱州唯佳网络科技有限公司 | 上海噪音治理公司-专业隔音降噪公司-中广通环保 | 石家庄救护车出租_重症转院_跨省跨境医疗转送_活动赛事医疗保障_康复出院_放弃治疗_腾康26年医疗护送转诊团队 | 大型冰雕-景区冰雕展制作公司,3D创意设计源头厂家-[赛北冰雕] | 食品无尘净化车间,食品罐装净化车间,净化车间配套风淋室-青岛旭恒洁净技术有限公司 | 活性炭-蜂窝-椰壳-柱状-粉状活性炭-河南唐达净水材料有限公司 | 全自动翻转振荡器-浸出式水平振荡器厂家-土壤干燥箱价格-常州普天仪器 | 粉碎机_塑料粉碎机_塑料破碎机厂家-星标机械 | 照相馆预约系统,微信公众号摄影门店系统,影楼管理软件-盟百网络 | 上海网站建设-上海网站制作-上海网站设计-上海做网站公司-咏熠软件 | 全自动五线打端沾锡机,全自动裁线剥皮双头沾锡机,全自动尼龙扎带机-东莞市海文能机械设备有限公司 | 不锈钢监控杆_监控立杆厂家-廊坊耀星光电科技有限公司 | 渣土车电机,太阳能跟踪器电机,蜗轮蜗杆减速电机厂家-淄博传强电机 | 吉祥新世纪铝塑板_生产铝塑板厂家_铝塑板生产厂家_临沂市兴达铝塑装饰材料有限公司 | 臭氧灭菌箱-油桶加热箱-原料桶加热融化烘箱-南京腾阳干燥设备厂 臭氧发生器_臭氧消毒机 - 【同林品牌 实力厂家】 | 有机肥设备生产制造厂家,BB掺混肥搅拌机、复合肥设备生产线,有机肥料全部加工设备多少钱,对辊挤压造粒机,有机肥造粒设备 -- 郑州程翔重工机械有限公司 | ERP企业管理系统永久免费版_在线ERP系统_OA办公_云版软件官网 | 重庆中专|职高|技校招生-重庆中专招生网 | 胀套-锁紧盘-风电锁紧盘-蛇形联轴器「厂家」-瑞安市宝德隆机械配件有限公司 | 液晶拼接屏厂家_拼接屏品牌_拼接屏价格_监控大屏—北京维康 | 石家庄小程序开发_小程序开发公司_APP开发_网站制作-石家庄乘航网络科技有限公司 | 高压微雾加湿器_工业加湿器_温室喷雾-昌润空气净化设备 | 杭州用友|用友软件|用友财务软件|用友ERP系统--杭州协友软件官网 | 合肥展厅设计-安徽展台设计-合肥展览公司-安徽奥美展览工程有限公司 | 防火阀、排烟防火阀、电动防火阀产品生产销售商-德州凯亿空调设备有限公司 |