View Full Version : Element CSS options

9 Jul 2010, 8:45 AM
So I'm still really new to Ext and I've been scouring the API and associated resources (google searches) and I'm trying to use Ext to get a DOM and set the css version of

margin-left: '0%', margin-right: 'auto', border-style: 'solid', border-color: '#cccccc'
Is there anyway to do this as it seems like it should be an easy task but setStyle() apparently doesn't like margin or border requests.

9 Jul 2010, 11:21 PM

'margin-left': '0',
'margin-right': 'auto',
'border-style': 'solid',
'border-color': '#cccccc'

Ext.get('id-of-element').setStyle('margin-left: 0, margin-right: auto, border-style: solid, border-color: #cccccc');

12 Jul 2010, 5:51 AM
I thought if you were using an object like that the options had to be quoted. Thanks for the heads up on this cause that just didn't seem to make any sense as to why I couldn't set those.

12 Jul 2010, 6:02 AM
You need quotes, because '-' is not a valid character for identifiers.

16 Jul 2010, 10:24 AM
Way late but in the end the way I had to get it fixed was just to use
border: 0 solid #CCCCCC instead of trying to set the three individually. Using the concatenated form worked fine.