Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [SOLVED] Make text height follow parent div Re: [SOLVED] Make text height follow parent div

#103391

Now, I got it to work, kind of.

The thing is, if I write the code you gave me:

// Cache the div so that the browser doesn’t have to find it every time the window is resized.
var $div = $(‘ul.menu’);

// 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’);‚Äč

It doesn’t work. If I put the var $div = $(‘ul.menu’); inside the function, it kind of works, but it doesn’t really follow the div, it just resizes and then stay there. And the text OUTSIDE of the ul.menu does also resize.