Line-height on class names not working!?

Why is that function not working? Try to increase the value of the line-height on all rectangles with the class name 'arbeit'. It is working with the height property, but not for line-height. Any suggestions?

var lineHeightXS = 50;
var hypeSceneElm = document.getElementById(hypeDocument.currentSceneId());
var searchResultElms = hypeSceneElm.getElementsByClassName('arbeit');
for (var i = 0; i < searchResultElms.length; i++)
{
	currentElm = searchResultElms[i];
hypeDocument.setElementProperty(currentElm,'line-height', lineHeightXS + 'px');
}

lineHeight.hype.zip (20.3 KB)

Not at mac at mo but I a syntax error.

You have a capital I++. When it should be lowrrcase
i++

That was just a copy and paste issue. In the Hype example the code is correct. But it's not working for this property line-height.

Is line-height a valid property name? When I add a valid property name the code works fine.

var lineHeightXS = 200;
var hypeSceneElm = document.getElementById(hypeDocument.currentSceneId());
var searchResultElms = hypeSceneElm.getElementsByClassName('arbeit');
for (var i = 0; i < searchResultElms.length; i++)
{
currentElm = searchResultElms[i];
// hypeDocument.setElementProperty(currentElm,'line-height', lineHeightXS + 'px');

currentElm.style.lineHeight = lineHeightXS + 'px';
}

There´s no Hype line-height property...

1 Like

setElementProperty belongs to Hypes API and line-height simply is not provided.

You may use a general approach by using CSSStyleDeclaration.

currentElm.style.setProperty('line-height', lineHeight + 'px', "important")

///////////
btw do you need js here?

2 Likes

getting old and slow ... :wink:

1 Like

Yeah, it's not a valid property name. I suspected that already. Then, it's just about the CSSStyleDeclaration. Thank you all :heart:

2 Likes

"Wiser, you become as older you grow."

1 Like