PDA

View Full Version : borderlayout question



jbowman
24 Oct 2006, 5:04 PM
Ok, I have this code...



Layout = {
init: function() {
var layout = new YAHOO.ext.BorderLayout(document.body, {
north: {
split:false,
initialSize: 35
},
south: {
split:false,
initialSize: 20,
},
center: {
autoScroll: true
}
});
layout.beginUpdate();
layout.add('north', new YAHOO.ext.ContentPanel('header', {fitToFrame:true}));
layout.add('south', new YAHOO.ext.ContentPanel('footer', {fitToFrame:true}));
layout.add('center', new YAHOO.ext.ContentPanel('content', {title: "body", fitToFrame:false}));
layout.endUpdate();



Any content I put into the div "content" is inheriting a setting of 100% width from somewhere. Is this the expected behaviour?

jack.slocum
24 Oct 2006, 5:57 PM
The content of the div 'content' (this may get confusing :) ) shouldn't get adjusted at all. But 'content' (the div) is a block element, and by default block elements expand to fill their container. Does that make sense?

jack.slocum
24 Oct 2006, 5:58 PM
Note: They expand their width, but not height.

jbowman
24 Oct 2006, 6:33 PM
elements within the block appear to be getting assigned as blocks as well...

nice thing about the new framework I'm working with... I don't have much done so it was easy enough for me to throw together a demo for you. I set red borders around the children blocks so you can see how they're getting stretched. Happening in north and south also.

http://whasit.com/demo.html

jack.slocum
25 Oct 2006, 6:50 AM
Your child element is a div. A div is a block element. It will automatically grow it's width to fill it's parent element.

jbowman
25 Oct 2006, 9:01 AM
ugh, i just did a test using basic html and see you're 100% correct, I have no idea why I was thinking a div's width was adjusted to fit that of it's content... Sorry about that Jack.

jack.slocum
25 Oct 2006, 3:40 PM
It's much better to ask questions than to just think somethings broken. I am guilty of giving up on something many times rather than asking a question.