|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Alter line-height CSS property based on image height and hyperlinks
Hi all,
I am trying to automate everything on my test website and I have one more angle to cover. In effect, I want to adjust the line-height property (which I can do) based on the number of files within a specific folder (PHP and already done). The more files in the folder, the lower the line-height value must be. This is to ensure if I copy additional files into the folder, then the navigation menu (which is PHP reading files in this particular folder) will alter the CSS line-height property accordingly to ensure it can never exceed a certain height. Sounds wierd? go to www.re3.org.uk (next to the RE3 image, I have a list of hyperlinks which are obtained from files within the folder) My problem, when adjusting the CSS property (which is set as cm in *.css file) in javascript, it doesn't correspond correctly, the line-height property in javascript doesn't appear to be work in cm but some other measurement. Does anyone know how to change what unit of measurement Javascript works in? Or does anyone know what unit of measurement javascript uses when adjusting line-height / line-width values? I want to create a mini-algorithm that works out the appropriate line-height based on the image height (got that already) and the number of files in the folder (got that too) so the menu automatically adjusts to fit. Whew! |
|
#2
|
|||
|
|||
|
I don't get how you've come to the conclusion that JavaScript is using it's own measurement system.
Say you have your containing element with an id of 'links', it has a line-height value set, simply put javascript doesn't really care what this value is and doesn't view it as anything but a value. For arguments sake lets say we're playing with ems... this is what we have in the css file. #links { line-height: 1.2em; } Now you want to adjust that with javascript here's what you do. document.getElementById('links').style.lineHeight = String('1.8em'); Simple as... you could even change the measurement type with the JS. Hope that makes some sense. -D |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > Alter line-height CSS property based on image height and hyperlinks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|