This fiddle provides a stripped-down example of what I'm trying to achieve. A lot is missing, but all relevant code is there.
Take a look at this fiddle. The goal is that the pink box fills up the space that's available in width (with a gap defined in CSS by margin-left
) and that it has the same height as the yellow part. Unfortunately only the first property (min-height
) is applied.
$(".banana + .strawberry").css({
"minHeight": function () {
var $this = $(this),
banana = $this.prev(".banana"),
bh = banana.outerHeight();
return bh;
},
"width": function () {
// Many variables, but they allow a highly
// customized CSS file
var $this = $(this),
margin_l = parseInt($this.css("marginLeft"), 10),
margin_r = parseInt($this.css("marginRight"), 10),
padding_l = parseInt($this.css("paddingLeft"), 10),
padding_r = parseInt($this.css("paddingRight"), 10),
border_l = parseInt($this.css("borderLeftWidth"), 10),
border_r = parseInt($this.css("borderRightWidth"), 10),
parent = $(this).parent(),
pw = parent.width(),
banana = $this.prev(".banana"),
bw = banana.outerWidth();
console.log(margin_l);
return (pw - bw - margin_l - margin_r - padding_l - padding_r - border_l - border_r);
}
});
For some reason all browsers accept this code, however IE8 doesn't. On my website I'm using jQuery 1.11.2. I tested IE8 in emulation mode. I also tried alerting some text inside the function
that ought to return the right value for width, but even that doesn't work. Can't you stack CSS properties in jQuery with IE8 that all depend on a function to return a value?