Search code examples
javacssgwtcssresource

how to access the styles from CSS


Can we get the value from inside a css definition in the code if CSS resource is used?

e.g.

.iv_menu_thumbnail {  
  display: block;  
  width: 24px;  
  height: 24px;  
  margin: 3px;  
  float: left;  
  cursor: pointer;  
}`

Can we know via code the value of width and i want to access from one of my java class?

Thanks in advance


Solution

  • var width = $('.iv_menu_thumbnail').width();
    console.log(width);
    

    This will get the width of the element if this is what youre asking for. As far as I'm concerned you cannot get non numerical values from a css declaration.

    But you can set your own values via jQuery using the

    .css()
    

    So it would look like this if you want to set a new css value. (or overwrite it)

    $(someelement).css('float', 'left');