我有以下 CSS。
.formhidden {overflow: hidden}
.formhidden[id*='petinfo_']
{height: 48px}
.formhidden[id*='petproblem_']
{height: 0px}
[id*='petinfo_']:not(.formhidden)
{outline: 1px solid black; padding: 24px 12px 12px}
[id*='petproblem_']:not(.formhidden)
{outline: 1px solid black; padding: 24px 12px 12px}
[id*='petinfo_']:not(.formhidden):not(nth-child(2))
{margin-top: -24px}
[id*='petproblem_']:not(.formhidden)
{margin-top: -24px}
[id*='petinfo_']:not(.formhidden) div [id*='petinfo_']
{margin-top: 24px}
[id*='petproblem_']:not(.formhidden) [id*='petinfo_']
{margin-top: 24px}
/* For any pet div with the formhidden class, hide all,
but reveal the pet's name unless it's the only pet so far.
This is sensitive to position from first and last sibling. */
.formhidden[id*='petinfo_'] *:not(:nth-child(4)):not(:nth-child(5)),
.formhidden[id*='petinfo_']:nth-child(2):nth-last-child(4) *,
.formhidden[id*='petproblem_'] *,
#ownerform.formhidden,
.formhidden.form_btn {visibility: hidden; height: 0px}
.formhidden[id*='petinfo_']:not(:nth-child(2):nth-last-child(4))
{outline: 1px solid black; margin-bottom: 24px}
在一個表單中,有以下 div,用這些 div 中的標簽和輸入分隔表單的各個部分。
<div id="ownerform"></div>
<div id="petinfo_0"></div>
<div id="petproblem_0"></div>
<div id="html_element_recaptcha"></div>
<div class="buttonholder"></div>
簡單地說,“.formhidden”類在應用時隱藏了一個部分。我有 javascript 應用并從部分中洗掉它,因此一次只能看到一個。javascript 還克隆 petinfo_0 和 petproblem_0 并將 0 增加到適當的數字。
它在 Chrome 和 Firefox 中運行良好。但是當我在 IE (Edge) 中嘗試它時,最后的 CSS 宣告不起作用。
.formhidden[id*='petinfo_']:not(:nth-child(2):nth-last-child(4))
{outline: 1px solid black; margin-bottom: 24px}
如果我們還沒有添加更多部分,則意味著排除 petinfo_0。(在我們的初始狀態下,它是從前面算起的第 2 個 div 和從最后算起的第 4 個 div。)
我已經嘗試了幾個小時來找出問題所在,但沒有任何效果。
編輯:事后看來,我實際上發現沒有出現任何輪廓,除了目前正在顯示的一個部分。因此,似乎這些帶有大綱的宣告都不起作用。
uj5u.com熱心網友回復:
從檔案中我們可以知道,并非所有瀏覽器都支持同時使用兩個選擇器。
如果您想在 IE 中使用它們,只需將其替換為:
.formhidden[id*='petinfo_']:not(:nth-child(2)):not(:nth-last-child(4)) {
outline: 1px solid black;
margin-bottom: 24px
}
uj5u.com熱心網友回復:
最后,如果它是 nth-child(x):last-child(y),我似乎必須重寫它。另外,IE 不支持 unset,所以我們必須顯式地用一個值覆寫它。
這對我有用:
.formhidden[id*='petinfo_']
{outline: 1px solid black; margin-bottom: 24px}
.formhidden[id*='petinfo_']:nth-child(2):nth-last-child(4)
{outline: 0px; margin-bottom: 0px}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/415845.html
標籤:
上一篇:通過InternetExplorer進行VBA螢屏抓取
下一篇:為什么更改InternetExplorer(版本11及更低版本)中的innerText會永久破壞所有后代文本節點?
