Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting width to % ????

Status
Not open for further replies.

bazjones

Programmer
Nov 17, 2004
5
NL
Hi i have no experience in javascript but i am using a javascript menu in my website and was wondering whether it is possible to set the width of my javascript menu as a percentage such as 100%???

Code i have is below:

Thanks

Code:
var MENU_POS = [
{
	//NAVIGATION BAR SETTINGS
	// item sizes
	'height': 15,     //height of naviagtion bar
	'width': 138,    // Length of navigation bar
	// menu block offset from the origin:
	//	for root level origin is upper left corner of the page
	//	for other levels origin is upper left corner of parent item
	'block_top':60,     //position from top of page
	'block_left': 0,    //position from left of page
	// offsets between items of the same level
	'top': 0,
	'left': 140,
	// time in milliseconds before menu is hidden after cursor has gone out
	// of any items
	'hide_delay': 600,
	'expd_delay': 100,
	'css' : {
		'outer': ['m0l0oout', 'm0l0oover'],
		'inner': ['m0l0iout', 'm0l0iover']
	}
},
{
     //DROP DOWN LIST SETTINGS
	'height': 16,
	'width': 250,
	'block_top': 17,
	'block_left': 0,
	'top': 17,
	'left': 0,
	'css': {
		'outer' : ['m0l1oout', 'm0l1oover'],
		'inner' : ['m0l1iout', 'm0l1iover']
	}
},
{
	'block_top': 4,
	'block_left': 240,
	'css': {
		'outer': ['m0l2oout', 'm0l2oover'],
		'inner': ['m0l1iout', 'm0l2iover']
	}
}
]
 
If you want it to be 100% set the width = screen.width

'width': screen.width, // Length of navigation bar


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Or for other percentages, use
Code:
var percent = 18;
var units = 100 / screen.width;
amout = percent * units;

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top