1

I have 2 unrelated elements: #A and #B (in terms of hierarchy). #A does not have a predefined height. I would like #B to end up being the height of #A minus 325px.

I know Sass can handle operations, but I am unsure of how to query the height of #A - is that even possible?

4

2 回答 2

1

使用 CSS 或 SASS 是不可能的,使用 jQuery 很容易:

$('#b').outerHeight( $('#a').outerHeight() - 325 );

演示:http: //jsbin.com/ulimon/2/edit

于 2013-07-16T10:32:32.537 回答
1

抱歉,但我认为无法使用 SASS 获得元素高度(我不是 sass 专家,但我找不到任何选项)。

我建议您使用 JavaScript 执行此操作:

http://jsfiddle.net/9DcYn/2/

window.onload = fixHeight();
function fixHeight() {
    var divh = document.getElementById('leftdiv').offsetHeight;
    var divhnum = new Number(divh);
    var setheight = (divhnum - 325);
    document.getElementById('rightdiv').style.height = setheight + 'px';
}

希望对你有帮助!

于 2013-07-16T04:10:56.773 回答