Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Mixing pixel and percentage values



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> HTML Forum
View previous topic :: View next topic  
Author Message
trobertson



Joined: 01 May 2008
Posts: 3

PostPosted: Thu May 01, 2008 1:51 am    Post subject: Mixing pixel and percentage values Reply with quote

Hi Folks,

I need to place a div element on a page and would like to set its top position at a specific pixel location, and I would like its height to take up the remainder of the available screen size. So the element's height changes as the screen size changes, but its top position is a fixed pixel value ... What makes this difficult (I think) is that I am trying to mix pixel and percentage values.

Can anyone suggest a solution? Does this require bunch of JS?

Thanks!
Back to top
View user's profile Send private message
rangana
250+ Club


Joined: 27 Feb 2008
Posts: 439
Location: Cebu City Philippines

PostPosted: Thu May 01, 2008 3:20 am    Post subject: Re: Mixing pixel and percentage values Reply with quote

The fixed height on top could just be done using CSS (position:fixed). While the height dilemma needs JS:

1.) Know your container's height if you're placing your divs inside a wrapper. Or know the body's height in which you want to base the remaining height and use offsetHeight to know your container/body's height Smile

2.) Do basic algebra (subtraction)

See if it helps Wink
Back to top
View user's profile Send private message Yahoo Messenger
trobertson



Joined: 01 May 2008
Posts: 3

PostPosted: Thu May 01, 2008 4:19 am    Post subject: Re: Mixing pixel and percentage values Reply with quote

I can set the top no problem. As you point out, the height is the dilemna. So, would you call a javascript function when the page loads to get the available screen size and change the css rule dynamically? If so, would this continue to work if the user changed the screen size by dragging the corner of the browser?

Thanks !!!
Back to top
View user's profile Send private message
rangana
250+ Club


Joined: 27 Feb 2008
Posts: 439
Location: Cebu City Philippines

PostPosted: Thu May 01, 2008 5:11 am    Post subject: Re: Mixing pixel and percentage values Reply with quote

I'm not certain...as I never had tried it, yet i've seen its effect taking in action here:
http://bonrouge.com/~fixH
Back to top
View user's profile Send private message Yahoo Messenger
trobertson



Joined: 01 May 2008
Posts: 3

PostPosted: Thu May 01, 2008 2:25 pm    Post subject: Re: Mixing pixel and percentage values Reply with quote

OK, I get it ... Thanks rangana !!!
Back to top
View user's profile Send private message
rangana
250+ Club


Joined: 27 Feb 2008
Posts: 439
Location: Cebu City Philippines

PostPosted: Fri May 02, 2008 1:57 am    Post subject: Re: Mixing pixel and percentage values Reply with quote

No problem, just get back if you're still stumped Wink
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> HTML Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap