| Page 1 of 1 | [ 5 posts ] |
|
Since the Layout Manager widget doesn't yet exist, I'm trying to create some code that mimics it's basic behavior (no animation, just creates the basic layout). So far I have the following:
Code: YUI().use('node','stylesheet',function(Y){ //Afix the footer to the bottom of the screen var head=Y.one('#header'); var headDim=head.get('region'); var main=Y.one('#main'); var foot=Y.one('#footer'); var footDim=foot.get('region'); var view=main.get('viewportRegion'); var mainHeight=view.height-headDim.height-footDim.height; main.setY(headDim.height); main.setStyle('height',mainHeight); foot.setY(view.height-footDim.height); var myStyles=Y.StyleSheet('myStyles'); myStyles.set('#container',{minHeight:mainHeight}); myStyles.set('#sidebar',{minHeight:mainHeight}); myStyles.set('#content',{minHeight:mainHeight}); }); Everything is working except for the min-height of container, sidebar, and content property being set in the stylesheet. I have to set the min-height using the stylesheet because not all screens will have a sidebar and the element won't always exist when this code runs. The code is not producing any errors, but it is not working either (when I check the stylesheet the min-height property does not exist. I am guessing the problem is the way I am referencing the id of the rule to update. All the examples I found were updating classes and not the named element. I tried it with and without the # but no dice either way. Any help or insight would be greatly appreciated. |
Juan Ignacio DopazoYUI Contributor
|
There is a Layout widget in the Gallery that seems to work very well. Here's an example: http://axosoft.github.com/yui3-gallery/ ... ayout.html
|
|
Thanks. I looked at that before, but I thought I would rather write my own as I really do not need anything that complex. Just a fixed header/footer and in certain contexts a left hand sidebar. The header/footer were easy enough, but the sidebar only exist in certain contexts which is why changing the stylesheet should be a good solution. If I set the min-height property in css, it functions just the way I need it to. The problem is I need to set the min-height property dynamically based on the viewport. You can't do this for an element that doesn't exist in the DOM yet, but manipulating the stylesheet should do the trick if I can figure it out.
All the examples seem to show using classes instead of the id. That wasn't my preference but I'll give that a try and see if it makes a difference. |
Francesco PongiluppiYUI Contributor
|
Ciao Kristopher,
I would suggest you to avoid messing up with the stylesheets in javascript. Everytime you touch the definitions the browser would redraw the entire page, even if you don't really change a thing. This could be a huge performance problem. Beside that, the browser oddities in handling the stylesheet rules are a pain that could kill that "not that complex" solution. Try to use the -debug version and look for the warnings that the StyleSheet module throws (maybe it's a somehow invalid selector). If anything else helps, use that gallery module |
|
I "sort of" figured out the problem. The part of the code that is not working is the part that references my existing style sheet. If I delete the container, sidebar, and content elements from my existing css sheet and remove the reference to myStyles then all works as expected.
|
| Page 1 of 1 | [ 5 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group