- Create Account

How to set percentage width&height ?

Forums > DHTML Scroller > How to set percentage width&height ?
Author
Message

1) telemach Group: Members
Posts: 10 Joined: 26 Nov 2007 Location: IP: 83.144.--.--
divs[n] = new ScrDiv('ID-of-div', 'Left', 'Top', 'Width',  'Height', Visibility, 'Parent');

width  and height are measured in pixels and I need to use percentage, the best would be 100% for both width and height as my content div is nested inside a div
that can be resized, putting something with % just spoils the script

shortly speaking something like :

divs[0]  = new ScrDiv('contentOuter', '0', '0', '100%',  '100%', 2);

as for now I'm using this :

divs[0]  = new ScrDiv('contentOuter', '0', '0', 'DivID.offsetWidth',  'DivID.offsetHeight', 2);

where DivID is the name of the div where 'content' div is nested in

but is this how it should be done ?
============

BTW: What about positioning ?

if  I have a certain div and want to nest the scrollbar in there like this

<div id="contentUpArrows">

left: 0px; top: 0px;

and

<div id="contentDownArrows">

left: 0px; bottom: 0px;

and <div  id="contentBar"> & <div id="contentThumb">

between them, do I have to build a table or div layout and then place these items inside or your script can be used to position everything ?

2) Angus Turnbull Group: Moderators
Posts: 4042 Joined: 7 Dec 2003 Location: New Zealand IP: 202.137.--.--
Try 'getRef('DivID').offsetWIdth * 0.60' to get 60% of that element width.

Also: Tables are bad, try to avoid them :).

If  you want you can just put the scrollbar elements inside your wrapping DIV and use CSS to position them as you really should anyway :). Either that or someone linked to a script called "flexscroll" recently that is a custom scrollbar built around more modern principles than this one!

- Angus.

3) telemach Group: Members
Posts: 10 Joined: 26 Nov 2007 Location: IP: 83.144.--.--
->Also: Tables are bad, try to avoid them :).

yeah  but I reached the CSS limitations and table is the only thing that do it's job

->If you  want you can just put the scrollbar elements inside your wrapping DIV and use CSS to position them as you really should anyway :).

it  turned out that in my case existing table is fine because I have one colum and three rows, first for upper arrow, second/middle for scrollbar, third for bottom arrow

I did manage to put every single element in nested div by wrapping with

<div  style="position:absolute"> SCROLLBAR HERE FOR EXAMPLE </div>
so  positioning values from the javascript will apply to this certain div and not the root page

Post a Reply:

You are not logged in, and will be posting anonymously as a guest. If you want to post using an account, please login at the top of this page.