太高我有一個reddit的新聞源在這裏:CSS動畫去懸停
https://codepen.io/Teeke/pen/YxXXaE
文章的標題出現在懸停。如果文章長度文本太長,則標題將超出視口,使前2-3個單詞無法閱讀。
我可以減少行高,但我想解決這個問題。
兩個選項:
1)使文章的文字上面去的圖片外,保持灰色覆蓋。
2)使彈出停在某個高度:頂部的文本是可讀的,但較低的文本將被隱藏。
這樣做的最佳做法是什麼?
我試過了,overflow:hidden;位置:固定;但都沒有給出可讀的結果。
CSS:
.overlay{
display: block;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 3;
// text-shadow: 2px 2px 2px #f22;
}
.bar, .overlay{
transition: transform 250ms;
transform: translateY(80px);
color: transparent;
}
&:hover{
.bar, .overlay{
transform: translateY(0);
color: inherit;
text-shadow: 2px 2px 2px #222;
background: linear-gradient(to top, #001, rgba(0,0,0,0.4) 5px);
padding: 8px;
}
}
&.stickied .overlay{
background: linear-gradient(to top, #0f0, transparent 80px);
}
@media (max-width: 520px){
width: 100% !important;
}
}
}
我想在這種情況下使用第二個選項,它會更好地使字體更小,這不會是一個問題 –
你是第二個建議使字體更小的人。我可能會這樣做。 :) – RubyRube