/    Sign up×
Community /Pin to ProfileBookmark

Overlapping Div Monster

my css …

[CODE]#lower {height: 50%; outline: none; overflow: auto;}
.content {padding: 18px; display: none;}
#home_left {width: 50%; white-space: nowrap; float: left;}
#home_right {width: 50%; float: right;}
#home_menu, #links_menu {width: 300px; margin: 0 auto; padding: 0 18px; background: #000000;}[/CODE]

my html …

[CODE]<div id=”lower”>
<div class=”content”>
<div id=”home_left”>some text content</div>
<div id=”home_right”>
<div id=”home_menu”>some other content</div>
</div></div></div>[/CODE]

The “descriptive concept” of the javascript I’m in need of help with …

window.onresize = new Function(“if (The Left Border’s, Screen Based (not style setting based) Pixel Position of document.getElementById(‘home_menu’) is <= The Right Border, Screen Based (not style setting based) Pixel Position of The Last Letter in The Longest Line of Text Inside of document.getElementById(‘home_menu’) document.getElementById(‘home_left’).style.whiteSpace = ‘normal’; else document.getElementById(‘home_left’).style.whiteSpace = ‘nowrap’;”);

How is THAT for crazy?

What I’m basically in need of help with is finding the horizontal screen pixel position of the “home_menu” left border (with margin) … FIRST (variable a)

Then I need to get the horizontal screen pixel position … of the last right hand pixel … of the longest text line within “home_right” … SECOND (ouch, variable b).

If variable a is less than variable b, change the whitespace to normal.

There’s probably a better way and I’d love to hear about it … but be forewarned, I’m not interested in “Just bite the bullet”, “You shouldn’t care about this”, or “Stop drinking expired milk.”

I enjoy expired milk. I feel it gives me an edge when asking ladies out on a date, especially now that I’m married. It’s as if they’re so into me that they can’t take it and run away. Oh yeah, I still got it.

Anyhow …

Originally I posted a vague description of my intentions to do this and one nice user pointed me to this script:

function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}

I can’t get this script to DO anything. Maybe FF doesn’t support offsetParent? I dunno, but … that’s apparently step one.

Nextly, I’m supposed to use a script located here: [url]http://www.aspandjavascript.co.uk/javascript/javascript_api/get_element_width_height.asp[/url]

I don’t need it to detect older browsers. I’m sticking with modern browsers only so I want to find a scaled down rendering of the same script.

After that it’s a matter of x-y coordinates.

I can’t even type anymore. This is going to be a pain. Anybody up for experimenting with me? If so … YOU start LOL. I have no idea where to begin.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @robindean spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...