有什么方法可以實際計算出最大內容或最小內容或適合內容等等。
就像是
.btn:hover {
width: calc(max-content);
}
我試過 (max-content 0px) 但也沒有用。需要一個純 CSS 解決方案。使用 JavaScript 應該是最后的優先事項!
uj5u.com熱心網友回復:
你想達到這樣的目標嗎?
.wrapper {
display: flex;
justify-content: center;
}
.hover-me {
flex-grow: 0;
cursor: pointer;
transition: flex-grow 1s cubic-bezier(.5,0,.3,1);
}
.hover-me:hover {
flex-grow: 1;
}
<div class="wrapper">
<button class="hover-me">hover me</button>
</div>
uj5u.com熱心網友回復:
.btn:hover{
width: 100%;/* for maximum space available to the button in parent element */
}
或者
.btn:hover{
width: 100%;/* for maximum space available to the button in window */
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/406459.html
標籤:
下一篇:如何在純CSS中修復此浮動標簽?
