[英]floating label not working correctly with not(:placeholder-shown)
[英]:not(:placeholder-shown) is not working with Adjacent sibling combinator
嗨:)我正在嘗試運行最簡單的示例:not(:placeholder-shown)並且它不起作用。這是我的codepen的鏈接。https://codepen.io/yael-screenovate/pen/eYJEqRB?editors=1100我做錯了什么? 提前謝謝。 繼承人的代碼:
button { display: none; } input:not(:placeholder-shown)+button { display: block; }
<div> <input/> <button>hi there</button> </div>
這是因為您沒有設置任何placeholder
屬性。
button { display: none; } input:not(:placeholder-shown)+button { display: block; }
<input placeholder="placeholder"/> <button>hi there</button>
不使用:not
更有意義,但整個邏輯相反:
button { display: block; } input:placeholder-shown+button { display: none; }
<input placeholder="placeholder" /> <button>hi there</button>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.