Re: Unable to get style property

15 views
Skip to first unread message
Message has been deleted

mocambo

unread,
Jul 6, 2008, 12:55:44 AM7/6/08
to Ruby on Rails: Spinoffs
In my previous message was an typo, so my question once again:

.css file contains:

.scrollbox_content {
padding: 5px

}

.js contains:

var content_div = document.createElement('div');
content_div.addClassName('scrollbox_content');
element.insert(content_div);

This "padding" is now visible but

$$('.scrollbox_content')[0].getStyle('padding')

gives "".


On Jul 6, 7:52 am, mocambo <moca...@hot.ee> wrote:
> .css file contains:
>
> .scrollbox_content {
> padding: 5px
>
> }
>
> .js contains:
>
> var content_div = document.createElement('div');
> content_div.addClassName('scrollbox_content');
> element.insert(this.content_div);
>
> This "padding" is now visible but
>
> $$('.scrollbox_content')[0].getStyle('padding')
>
> gives "".

kangax

unread,
Jul 6, 2008, 12:36:19 PM7/6/08
to Ruby on Rails: Spinoffs
Try:

parseFloat($$('.scrollbox_content')[0].getStyle('paddingLeft'), 10);

-- kangax

mocambo

unread,
Jul 6, 2008, 3:42:28 PM7/6/08
to Ruby on Rails: Spinoffs
Element.getstyle() reads element style values. And the current values
are:

$$('.scrollbox_content')[0].style.padding = "";
$$('.scrollbox_content')[0].style.paddingLeft = "";
$$('.scrollbox_content')[0].style.paddingTop = "";
$$('.scrollbox_content')[0].style.paddingBottom = "";
$$('.scrollbox_content')[0].style.paddingRight = "";

But browser shows 5px padding anyway. How to get these paddings ?

mocambo

unread,
Jul 6, 2008, 5:15:29 PM7/6/08
to Ruby on Rails: Spinoffs
Kangax, you were right ... getStyle returns values for 'paddingTop',
'paddingRight', 'paddingLeft', 'paddingBottom'.
Reply all
Reply to author
Forward
0 new messages