0

It's very interested is there way to connect CSS styles and UI custom class. For example create class what inherited UIButton class and add CSS styles to them. Is it possible?

EDIT My css:

.button {
   border: 3px solid #0a3c59;
   background: #3e779d;
   background: -webkit-gradient(linear, left top, left bottom, from(#65a9d7), to(#3e779d));
   background: -webkit-linear-gradient(top, #65a9d7, #3e779d);
   background: -moz-linear-gradient(top, #65a9d7, #3e779d);
   background: -ms-linear-gradient(top, #65a9d7, #3e779d);
   background: -o-linear-gradient(top, #65a9d7, #3e779d);
   background-image: -ms-linear-gradient(top, #65a9d7 0%, #3e779d 100%);
   padding: 20px 40px;
   -webkit-border-radius: 10px;
   -moz-border-radius: 10px;
   border-radius: 10px;
   -webkit-box-shadow: rgba(255,255,255,0.4) 0 1px 0, inset rgba(255,255,255,0.4) 0 1px 0;
   -moz-box-shadow: rgba(255,255,255,0.4) 0 1px 0, inset rgba(255,255,255,0.4) 0 1px 0;
   box-shadow: rgba(255,255,255,0.4) 0 1px 0, inset rgba(255,255,255,0.4) 0 1px 0;
   text-shadow: #7ea4bd 0 1px 0;
   color: #06426c;
   font-size: 9px;
   font-family: helvetica, serif;
   text-decoration: none;
   vertical-align: middle;
}
.button:hover {
   border: 3px solid #0a3c59;
   text-shadow: #1e4158 0 1px 0;
   background: #3e779d;
   background: -webkit-gradient(linear, left top, left bottom, from(#65a9d7), to(#3e779d));
   background: -webkit-linear-gradient(top, #65a9d7, #3e779d);
   background: -moz-linear-gradient(top, #65a9d7, #3e779d);
   background: -ms-linear-gradient(top, #65a9d7, #3e779d);
   background: -o-linear-gradient(top, #65a9d7, #3e779d);
   background-image: -ms-linear-gradient(top, #65a9d7 0%, #3e779d 100%);
   color: #fff;
}
.button:active {
  text-shadow: #1e4158 0 1px 0;
  border: 3px solid #0a3c59;
  background: #65a9d7;
  background: -webkit-gradient(linear, left top, left bottom, from(#3e779d), to(#3e779d));
  background: -webkit-linear-gradient(top, #3e779d, #65a9d7);
  background: -moz-linear-gradient(top, #3e779d, #65a9d7);
  background: -ms-linear-gradient(top, #3e779d, #65a9d7);
  background: -o-linear-gradient(top, #3e779d, #65a9d7);
  background-image: -ms-linear-gradient(top, #3e779d 0%, #65a9d7 100%);
  color: #fff;
}

And my class is inherited from UIButton class without any other changes. I want only add css properties.

5
  • 1
    yes it's possible you can change/add new css property, but little complicated, make sure that no JavaScript effected if added... Commented Aug 26, 2012 at 18:14
  • can you give me some example or link to some tutorial? Commented Aug 26, 2012 at 18:54
  • check this question, i think this may helpful for you.. stackoverflow.com/questions/1308369/… Commented Aug 26, 2012 at 19:32
  • @K.K I don't see how can I add css to my class.. Commented Aug 26, 2012 at 20:36
  • can you put here your CSS and UI custom class so that i can explain... Commented Aug 27, 2012 at 6:51

1 Answer 1

0

It Should work.

<script>
jQuery(function(){
    // add your own class
    jQuery(".button").addClass("ui-button-new-css");

    jQuery(".button.ui-button-new-css").hover(function(){
        jQuery(this).addClass("ui-button-new-css-hover");
    }, function(){
        jQuery(this).removeClass("ui-button-new-css-hover");
    });

    jQuery(".button.ui-button-new-css").focus(function(){
        jQuery(this).addClass("ui-button-new-css-active");
    });

    jQuery(".button.ui-button-new-css").blur(function(){
        jQuery(this).removeClass("ui-button-new-css-active");
    });
});
</script>

<style>
    .button.ui-button-new-css { 
        /* your new css property */
    }
    .button.ui-button-new-css.ui-button-new-css-hover { 
        /* your new hover css property */
    }
    .button.ui-button-new-css.ui-button-new-css-active { 
        /* your new active css property */
    }
</style>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.