久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

定位位置:當前處于“卡住"狀態(tài)的粘性元素

Targeting position:sticky elements that are currently in a #39;stuck#39; state(定位位置:當前處于“卡住狀態(tài)的粘性元素)
本文介紹了定位位置:當前處于“卡住"狀態(tài)的粘性元素的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

位置:粘性適用于某些移動設(shè)備瀏覽器,因此您可以讓菜單欄隨頁面一起滾動,但只要用戶滾動經(jīng)過它,它就會停留在視口的頂部.

position: sticky works on some mobile browsers now, so you can make a menu bar scroll with the page but then stick to the top of the viewport whenever the user scrolls past it.

但是,如果您想在粘性菜單欄當前固定"時稍微重新設(shè)置它的樣式怎么辦?例如,您可能希望欄在與頁面一起滾動時具有圓角,但是一旦它粘在視口的頂部,您就想擺脫頂部的圓角,并在下面添加一點陰影它.

But what if you want to restyle your sticky menu bar slightly whenever it's currently 'sticking'? eg, you might want the bar to have rounded corners whenever it's scrolling with the page, but then as soon as it sticks to the top of the viewport, you want to get rid of the top rounded corners, and add a little drop shadow underneath it.

是否有任何類型的偽選擇器(例如 ::stuck)來定位當前具有 position:sticky 的元素?或者瀏覽器供應(yīng)商是否有類似的東西正在籌備中?如果沒有,我在哪里申請?

Is there any kind of pseudoselector (eg ::stuck) to target elements that have position: sticky and are currently sticking? Or do browser vendors have anything like this in the pipeline? If not, where would I request it?

注意.javascript 解決方案對此并不好,因為在移動設(shè)備上,當用戶松開手指時,您通常只會收到一個 scroll 事件,因此 JS 無法知道通過滾動閾值的確切時刻.

NB. javascript solutions are not good for this because on mobile you usually only get a single scroll event when the user releases their finger, so JS can't know the exact moment that the scroll threshold was passed.

推薦答案

目前沒有為當前卡住"的元素推薦選擇器.定義 position:sticky 的 Postioned Layout 模塊 也沒有提及任何此類選擇器.

There is currently no selector that is being proposed for elements that are currently 'stuck'. The Postioned Layout module where position: sticky is defined does not mention any such selector either.

可以將 CSS 的功能請求發(fā)布到 www-style 郵件列表.我相信 :stuck 偽類比 ::stuck 偽元素更有意義,因為您正在尋找處于該狀態(tài)的元素本身.事實上,討論了一個 :stuck 偽類以前;人們發(fā)現(xiàn),主要的復雜情況是困擾著任何試圖基于渲染或計算樣式進行匹配的選擇器:循環(huán)依賴.

Feature requests for CSS can be posted to the www-style mailing list. I believe a :stuck pseudo-class makes more sense than a ::stuck pseudo-element, since you're looking to target the elements themselves while they are in that state. In fact, a :stuck pseudo-class was discussed some time ago; the main complication, it was found, is one that plagues just about any proposed selector that attempts to match based on a rendered or computed style: circular dependencies.

:stuck 偽類的情況下,最簡單的循環(huán)情況將使用以下 CSS:

In the case of a :stuck pseudo-class, the simplest case of circularity would occur with the following CSS:

:stuck { position: static; /* Or anything other than sticky/fixed */ }
:not(:stuck) { position: sticky; /* Or fixed */ }

而且可能還有更多難以解決的極端情況.

And there could be many more edge cases that would be difficult to address.

雖然人們普遍認為擁有基于某些布局狀態(tài)匹配的選擇器會很好,但不幸的是,存在主要限制使得這些限制難以實現(xiàn).我不會在短時間內(nèi)為這個問題的純 CSS 解決方案屏住呼吸.

While it's generally agreed upon that having selectors that match based on certain layout states would be nice, unfortunately major limitations exist that make these non-trivial to implement. I wouldn't hold my breath for a pure CSS solution to this problem anytime soon.

這篇關(guān)于定位位置:當前處于“卡住"狀態(tài)的粘性元素的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Style every third element?(每隔三個元素設(shè)置樣式?)
Why shouldn#39;t I use ID selectors in CSS?(為什么我不應(yīng)該在 CSS 中使用 ID 選擇器?)
What does img[class*=quot;alignquot;] mean in CSS?(CSS 中的 img[class*=“align] 是什么意思?)
CSS: Last element on line(CSS:最后一個元素)
How do I select every other div class element using just CSS (no js)(如何僅使用 CSS(無 js)選擇所有其他 div 類元素)
Tool for checking unused CSS selectors?(檢查未使用的 CSS 選擇器的工具?)
主站蜘蛛池模板: 欧洲精品在线观看 | 欧美视频三区 | 国产欧美日韩一区 | 一区二区三区国产 | 男人的天堂在线视频 | 四虎影院在线观看av | 色综合av| 欧美成人免费在线视频 | 一区二区三区亚洲视频 | 97精品一区二区 | 精品久久久久久久久久久久久久久久久 | 天天澡天天狠天天天做 | 日韩av在线一区二区 | 一级黄色绿像片 | 美女福利视频 | 99这里只有精品 | 日韩在线视频精品 | 国产激情福利 | 一道本不卡视频 | 黑人粗黑大躁护士 | 欧美精品一级 | 国产精品久久99 | 激情毛片 | 天天搞夜夜操 | 成人网在线看 | www.久久99 | 成年人黄色一级毛片 | 国产一级片免费视频 | 97操操| 国产一区二区三区在线免费观看 | 九九久久国产 | 美女黄色在线观看 | 久草新在线 | 欧美视频三区 | 亚洲天堂网站 | 日韩免费激情视频 | 国产精品不卡一区 | 免费一级片 | 国产一级视频免费播放 | 国产成人精品999在线观看 | 日本福利一区 |