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

  1. <small id='EOKVt'></small><noframes id='EOKVt'>

    • <bdo id='EOKVt'></bdo><ul id='EOKVt'></ul>
      <i id='EOKVt'><tr id='EOKVt'><dt id='EOKVt'><q id='EOKVt'><span id='EOKVt'><b id='EOKVt'><form id='EOKVt'><ins id='EOKVt'></ins><ul id='EOKVt'></ul><sub id='EOKVt'></sub></form><legend id='EOKVt'></legend><bdo id='EOKVt'><pre id='EOKVt'><center id='EOKVt'></center></pre></bdo></b><th id='EOKVt'></th></span></q></dt></tr></i><div class="qk0mgsw" id='EOKVt'><tfoot id='EOKVt'></tfoot><dl id='EOKVt'><fieldset id='EOKVt'></fieldset></dl></div>
    1. <tfoot id='EOKVt'></tfoot>

      <legend id='EOKVt'><style id='EOKVt'><dir id='EOKVt'><q id='EOKVt'></q></dir></style></legend>
    2. z-index 未按預期工作

      z-index not working as intended(z-index 未按預期工作)

      <tfoot id='s5YvV'></tfoot>

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

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

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

                本文介紹了z-index 未按預期工作的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我目前正在使用 Leaflet 和 Mapbox 創建自定義地圖.在我開始處理彈出窗口之前,一切都運行良好.

                我的情況:我有一個將要使用的自定義導航/控制面板,但它需要任何打開的彈出窗口之后(目前不是).

                我準備了一個

                我的 CSS 的一部分是

                #map-nav {位置:絕對;左:10px;頂部:10px;z指數:2;}.leaflet-popup-窗格,.leaflet-popup {z-index:1000!重要;}

                默認傳單類的 z-index 為 7(我認為),我只是將其重寫為 100% 確定.在瀏覽器(FF/Chrome)中檢查代碼時,我看到 z-index 設置正確,并且 .leaflet-popup 中的其他元素沒有任何 z-index 設置.

                我已經讀到否定的 z-index 可以解決這個問題,但是當我使用多個元素時,我真的很喜歡一個不那么hacky"的解決方案——如果有的話.(也歡迎使用 JavaScript 解決方案,因此使用標簽)

                從代碼檢查中我可以看到,Leaflet 為 .leaflet-popup 設置了一些屬性,這些屬性在位置方面是:transform: translate3d(..)bottomleft.

                感謝任何幫助.

                我可以把 #map-nav 放在 #map-content 里面,但還是不行):

                1. #map-nav 移動到 .leaflet-map-pane
                2. 創建一個 MutationObserver 并觀察 .leaflet-map-pane 的屬性變化.
                3. 每當 .leaflet-map-panestyle 屬性發生變化時,抓取它的 style.transform 屬性并提取 x 和 y 值.反轉這些值并將它們應用到 #map-nav.

                var map = L.map('map-content', {縮放控制:假}).setView([51.505, -0.09], 13);L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {attribution: '地圖數據和副本;<a >OpenStreetMap</a>貢獻者,<a >CC-BY-SA</a>,圖像 ? <a rauschundrausch.cih3gisks00r8rlly0ob5s2me',訪問令牌:'pk.eyJ1IjoicmF1c2NodW5kcmF1c2NoIiwiYSI6ImNpaTYyeW14MTAwNml2eW0zcmR6aHIzdDcifQ.6T8nzYq49rFnvcqk6lgYPg'}).addTo(地圖);var marker = L.marker([51.5, -0.09]).addTo(map);marker.bindPopup("這是一個<br>大<br>popup<br>在<br>高度方面");var mapNav = document.getElementById("map-nav");var mapPane = document.querySelector(".leaflet-map-pane");var rxTranslate =/translate(?:3d)?(([^)]+))/i;mapPane.appendChild(mapNav);var觀察者=新MutationObserver(函數(突變){if (mutations.some(m => m.attributeName === "style")) {//應用逆變換mapNav.style.transform = "翻譯(" + mapPane.風格.轉變.match(rxTranslate)[1].分裂(",").slice(0, 2)/* 只提取 x 和 y;丟棄 z */.map(n => parseFloat(n) * -1 + "px")/* 反轉值 */+ ")";}});觀察者.觀察(mapPane,{屬性:真});

                #map {位置:固定;頂部:0;右:0;底部:0;左:0;}#地圖導航{位置:絕對;左:10px;頂部:10px;寬度:100px;高度:100px;背景顏色:#ccc;z 指數:200;盒子陰影:插圖 0 0 0 1px #f00;}#地圖內容{寬度:100%;高度:100%;}.傳單彈出窗格{z指數:3;}

                <link rel="stylesheet" /><script src="https://code.jquery.com/jquery-2.1.4.min.js"></script><script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script><div id="地圖"><div id="地圖內容"><div id="map-nav"></div></div></div>

                這可能會在拖動時在某些客戶端上滯后.您可以使用超時來推遲更新,但這意味著導航菜單會四處移動,直到您停止拖動.

                I am currently working with Leaflet and Mapbox to create a custom map. All has been working fine until I started to work on the popups.

                My situation: I have a custom navigation/control panel that will be used but it needs to be behind any open popups (which it currently is not).

                I have prepared a JSFiddle and this screenshot

                Part of my CSS is

                #map-nav {
                  position: absolute;
                  left: 10px;
                  top: 10px;
                  z-index: 2;
                }
                .leaflet-popup-pane, .leaflet-popup {
                  z-index: 1000 !important;
                }
                

                The default leaflet classes have z-index of 7 (I think), I just overwrote it to be 100% sure. When inspecting the code in browser (FF/Chrome), I see that the z-index is set properly and no other element in the .leaflet-popup has any z-index set.

                I have read that negative z-index may solve this, but as I am working with multiple elements I'd really much like a less "hacky" solution - if there is one. (JavaScript solutions are welcome as well, hence the tag)

                As I can see from the code inspection, Leaflet sets some attributes to .leaflet-popup which in terms of position are: transform: translate3d(..), bottom and left.

                Any help is appreciated.

                Edit:

                I can put the #map-nav inside #map-content and it still won't work fiddle. However, when I try to imitate this without alle the map stuff, it does work.

                解決方案

                The problem is that #map-nav exists in an entirely different stacking context than the marker and its popup.

                The way you have it set up right now, the entire map is behind #map-nav. So, changing the z-index on either #map-nav or the .leaflet-popup-pane won't really help.

                Disclaimer: This is a terrible, terrible hack. If you look into Leaflet's documentation and find a way to add your own widgets, I'd highly recommend doing that instead of this.

                That said, I have something which sort of works (your mileage may vary):

                1. Move #map-nav into .leaflet-map-pane
                2. Create a MutationObserver and observe changes to the attributes of .leaflet-map-pane.
                3. Whenever the style attribute of .leaflet-map-pane changes, grab its style.transform property and extract the x and y values. Invert those values and apply them to #map-nav.

                var map = L.map('map-content', {
                  zoomControl: false
                }).setView([51.505, -0.09], 13);
                L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
                  attribution: 'Map data &copy; <a >OpenStreetMap</a> contributors, <a >CC-BY-SA</a>, Imagery ? <a ,
                  maxZoom: 18,
                  id: 'rauschundrausch.cih3gisks00r8rlly0ob5s2me',
                  accessToken: 'pk.eyJ1IjoicmF1c2NodW5kcmF1c2NoIiwiYSI6ImNpaTYyeW14MTAwNml2eW0zcmR6aHIzdDcifQ.6T8nzYq49rFnvcqk6lgYPg'
                }).addTo(map);
                
                var marker = L.marker([51.5, -0.09]).addTo(map);
                marker.bindPopup("this is a<br>large<br>popup<br>in<br>terms of height");
                
                var mapNav = document.getElementById("map-nav");
                
                var mapPane = document.querySelector(".leaflet-map-pane");
                
                var rxTranslate = /translate(?:3d)?(([^)]+))/i;
                
                mapPane.appendChild(mapNav);
                
                var observer = new MutationObserver(function(mutations) {
                  if (mutations.some(m => m.attributeName === "style")) {
                    // apply an inverse transform
                    mapNav.style.transform = "translate(" + mapPane
                      .style
                      .transform
                      .match(rxTranslate)[1]
                      .split(",")
                      .slice(0, 2) /* extract only x and y; discard z */
                      .map(n => parseFloat(n) * -1 + "px") /* invert values */ + ")";
                  }
                });
                
                observer.observe(mapPane, {
                  attributes: true
                });

                #map {
                  position: fixed;
                  top: 0;
                  right: 0;
                  bottom: 0;
                  left: 0;
                }
                #map-nav {
                  position: absolute;
                  left: 10px;
                  top: 10px;
                  width: 100px;
                  height: 100px;
                  background-color: #ccc;
                  z-index: 200;
                  box-shadow: inset 0 0 0 1px #f00;
                }
                #map-content {
                  width: 100%;
                  height: 100%;
                }
                .leaflet-popup-pane {
                  z-index: 3;
                }

                <link rel="stylesheet"  />
                <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
                <script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script>
                <div id="map">
                  <div id="map-content">
                    <div id="map-nav"></div>
                  </div>
                </div>

                This may lag on some clients while dragging. You could use a timeout to defer the update but that would mean the nav menu would move around until you stop dragging.

                這篇關于z-index 未按預期工作的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                Check if a polygon point is inside another in leaflet(檢查一個多邊形點是否在傳單中的另一個內部)
                Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標記群集圖標顏色,繼承其余默認 CSS 屬性)
                Trigger click on leaflet marker(觸發點擊傳單標記)
                How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認加載磁貼顏色?)
                Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側邊欄)
                Leaflet - get latitude and longitude of a marker inside a pop-up(Leaflet - 在彈出窗口中獲取標記的緯度和經度)

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

                        1. 主站蜘蛛池模板: 美国PARKER齿轮泵,美国PARKER柱塞泵,美国PARKER叶片泵,美国PARKER电磁阀,美国PARKER比例阀-上海维特锐实业发展有限公司二部 | 层流手术室净化装修-检验科ICU改造施工-华锐净化工程-特殊科室建设厂家 | 组织研磨机-高通量组织研磨仪-实验室多样品组织研磨机-东方天净 传递窗_超净|洁净工作台_高效过滤器-传递窗厂家广州梓净公司 | 金属雕花板_厂家直销_价格低-山东慧诚建筑材料有限公司 | MES系统工业智能终端_生产管理看板/安灯/ESOP/静电监控_讯鹏科技 | 氢氧化钙设备, 氢氧化钙生产线-淄博惠琛工贸有限公司 | 防火窗_耐火窗_防火门厂家_防火卷帘门-重庆三乐门业有限公司 | 托利多电子平台秤-高精度接线盒-托利多高精度电子秤|百科 | 仿真茅草_人造茅草瓦价格_仿真茅草厂家_仿真茅草供应-深圳市科佰工贸有限公司 | 药品冷藏箱厂家_低温冰箱_洁净工作台-济南欧莱博电子商务有限公司官网 | EDLC超级法拉电容器_LIC锂离子超级电容_超级电容模组_软包单体电容电池_轴向薄膜电力电容器_深圳佳名兴电容有限公司_JMX专注中高端品牌电容生产厂家 | 英国公司注册-新加坡公司注册-香港公司开户-离岸公司账户-杭州商标注册-杭州优创企业 | 金属回收_废铜废铁回收_边角料回收_废不锈钢回收_废旧电缆线回收-广东益夫金属回收公司 | 智慧食堂_食堂管理系统_食堂订餐_食堂消费系统—客易捷 | 杭州荣奥家具有限公司-浙江办公家具,杭州办公家具厂 | 成都离婚律师|成都结婚律师|成都离婚财产分割律师|成都律师-成都离婚律师网 | 广州昊至泉水上乐园设备有限公司 | 集装袋吨袋生产厂家-噸袋廠傢-塑料编织袋-纸塑复合袋-二手吨袋-太空袋-曹县建烨包装 | 车间除尘设备,VOCs废气处理,工业涂装流水线,伸缩式喷漆房,自动喷砂房,沸石转轮浓缩吸附,机器人喷粉线-山东创杰智慧 | 地脚螺栓_材质_标准-永年县德联地脚螺栓厂家 | 压接机|高精度压接机|手动压接机|昆明可耐特科技有限公司[官网] 胶泥瓷砖胶,轻质粉刷石膏,嵌缝石膏厂家,腻子粉批发,永康家德兴,永康市家德兴建材厂 | 3D全息投影_地面互动投影_360度立体投影_水幕灯光秀 | 广东银虎 蜂窝块状沸石分子筛-吸附脱硫分子筛-萍乡市捷龙环保科技有限公司 | 诚暄电子公司首页-线路板打样,pcb线路板打样加工制作厂家 | 河南生物显微镜,全自动冰冻切片机-河南荣程联合科技有限公司 | 六维力传感器_六分量力传感器_模腔压力传感器-南京数智微传感科技有限公司 | 培训中心-海南香蕉蛋糕加盟店技术翰香原中心官网总部 | 低温等离子清洗机(双气路进口)-嘉润万丰 | 阁楼货架_阁楼平台_仓库仓储设备_重型货架_广州金铁牛货架厂 | 杭州用友|用友软件|用友财务软件|用友ERP系统--杭州协友软件官网 | 超高频感应加热设备_高频感应电源厂家_CCD视觉检测设备_振动盘视觉检测设备_深圳雨滴科技-深圳市雨滴科技有限公司 | Q361F全焊接球阀,200X减压稳压阀,ZJHP气动单座调节阀-上海戎钛 | 智能监控-安防监控-监控系统安装-弱电工程公司_成都万全电子 | 刺绳_刀片刺网_刺丝滚笼_不锈钢刺绳生产厂家_安平县浩荣金属丝网制品有限公司-安平县浩荣金属丝网制品有限公司 | 电动手术床,医用护理床,led手术无影灯-曲阜明辉医疗设备有限公司 | 品牌广告服务平台,好排名,好流量,好生意。 | 气动机械手-搬运机械手-气动助力机械手-山东精瑞自动化设备有限公司 | 全自动定氮仪-半自动凯氏定氮仪厂家-祎鸿仪器 | 液氮罐_液氮容器_自增压液氮罐_杜瓦瓶_班德液氮罐厂家 | 土壤肥料养分速测仪_测土配方施肥仪_土壤养分检测仪-杭州鸣辉科技有限公司 | 半自动预灌装机,卡式瓶灌装机,注射器灌装机,给药器灌装机,大输液灌装机,西林瓶灌装机-长沙一星制药机械有限公司 | 陶瓷砂磨机,盘式砂磨机,棒销式砂磨机-无锡市少宏粉体科技有限公司 |