亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

檢查輸入 html 中的屬性,以便在塊位置不同時隱藏 css 內容

檢查輸入 html 中的屬性,以便在塊位置不同時隱藏 css 內容

慕標琳琳 2024-01-03 16:35:29
問題是 - 我可以像下面的代碼那樣將輸入與按鈕連接起來嗎?或者不改變 html 是不可能的(如果我不會為此使用 js 代碼)。不要責罵 html 代碼,這個例子來自一個網站,我只是想弄清楚是否可以訪問給定嵌套的其他塊。input:checked ~ button{    display: none;  }<div  id="form">    <section class="container">        <form class="form">            <section class="checkbox-control">                <label for="personal-data-checkbox" class="checkbox-border">                    <input type="checkbox"  id="personal-data-checkbox">                </label>                <label for="personal-data-checkbox" class="checkbox-label">                    <span class="consent-message"></span>                </label>            </section>            <section class="checkbox-control">                <label for="cookie-checkbox" class="checkbox-border">                    <input type="checkbox"  id="cookie-checkbox">                </label>                <label for="cookie--checkbox" class="checkbox-label">                    <span> </span>                </label>            </section>            <section class="buttons">                <section class="confirm">                    <button class="accept-all-button button">Agree to all</button>                    <button class="confirm-button button hidden-button">Confirm</button>                </section>            </section>            </form>    </section></div>
查看完整描述

1 回答

?
POPMUISE

TA貢獻1765條經驗 獲得超5個贊

我可以用按鈕連接輸入嗎

不,你無法連接。截至 2020 年 4 月,沒有選擇器可以從子項中選擇父項

然而https://dev.w3.org/csswg/selectors4/#relational,該文檔說他們將包括:has()selecor。使用它你可以這樣做

.checkbox-control:has(input:checked) ~ .buttons button {
      display: none;
}

但目前不支持



查看完整回答
反對 回復 2024-01-03
  • 1 回答
  • 0 關注
  • 149 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號