我正在尝试使文本的高度为 100%div
但它不起作用。
它只是变成了100%body { font-size:?; }
.
有什么办法让它跟随div高度吗?
The div
高度是整个页面的 4%,当您调整大小/更改分辨率时,我不希望文本跟随它。
为了获得我想要的结果,我必须使用以下代码:
// Cache the div so that the browser doesn't have to find it every time the window is resized.
var $div = $('li.leaf.item');
// Run the following when the window is resized, and also trigger it once to begin with.
$(window).resize(function () {
// Get the current height of the div and save it as a variable.
var height = $div.height();
// Set the font-size and line-height of the text within the div according to the current height.
$div.css({
'font-size': (height/2) + 'px',
'line-height': height + 'px'
})
}).trigger('resize');
感谢 joshuanhibbert@css-tricks 的帮助!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)