Essentially the idea is to make Element-B
and Element-C
to cover the area horizontally starting from center of Element-A
and ending at the edge of viewport
.
So, I gues开发者_JAVA技巧s i want to get the distance value from the center of Element-A
to the edge of viewport
Additional notes:
Element-A
doesnt have static position or size.Element-B
andElement-C
verticalposition or height is irrelevant.
I was thinking something like this:
- Calculate width of
Element-A
and divide it by two ( Or just get half the width if theres a way. ) - Get the distance from the edge of
Element-A
to the edge ofViewport
- Add up these calculated values.
( Of course unless theres way to get that this width straight up )
I was trying to look for a way to do list item 2. but couldnt find a way to do that.. and that more or less screws up my idea..
I have no starting point except the basic set-up for the images http://jsfiddle.net/nsEth/
Any ideas?
Something like this? http://jsfiddle.net/nsEth/1/
var a = $('#Element-A'),
b = $('#Element-B'),
c = $('#Element-C'),
aw;
$(window).resize(function() {
b.width( aw = a.offset().left + a.width()/2 );
c.width( $(window).width() - aw).css('left', aw);
}).resize();
精彩评论