Javascript脚本:
var resize = function () {
// 计算渲染后的实际宽度
document.querySelectorAll('.Lyrics_box').forEach( function(ele) {
var width = parseFloat(window.getComputedStyle( ele, null ).getPropertyValue('width'));
if(width < 720) {
ele.querySelectorAll('.Lyrics_original, .Lyrics_translated').forEach( function(self) {
self.style.width = '100%';
});
}
else {
ele.querySelectorAll('.Lyrics_original, .Lyrics_translated').forEach( function(self) {
self.style.width = '';
});
}
});
};
window.addEventListener('load', resize);
window.addEventListener('resize', resize);
//
CSS样式表:
*/
.Lyrics_box {
max-width: 1080px;
white-space: pre-wrap;
}
.Lyrics_original, .Lyrics_translated {
width:calc(50% - 5px);
display: inline-block;
vertical-align:top;
}
.Lyrics_original {
margin-right:10px;
}
.Lyrics_has_ruby {
line-height: 2.1;
}
@media only screen and (max-width:720px) {
.Lyrics_box {
width: 100% !important;
}
.Lyrics_original, .Lyrics_translated {
width:100%;
}
.Lyrics_original {
margin-right:0;
}
}
.Lyrics_gradient {
-webkit-background-clip: text;
background-clip: text;
-webkit-box-decoration-break: clone;
-webkit-text-fill-color: transparent;
text-fill-color: transparent;
position:relative;
}
.Lyrics_gradient ruby, .Lyrics_gradient rb, .Lyrics_gradient rt {
background: inherit;
}
.skin-minerva .Lyrics_gradient:hover::before,
.skin-minerva .Lyrics_single:hover::before {
content:attr(title);
position:absolute;
top:100%;
width:100%;
z-index:10;
text-align:center;
background:#fff;
font-size:0.7em;
border:1px solid #a7d7f9;
border-radius: 4px;
padding:0 3px;
box-shadow:1px 1px 1px #ccc;
color:#000;
-webkit-text-fill-color: initial;
text-fill-color: initial;
}
/*