1

I would like to make a timepicker similar to the datepicker, conforming to the current UI Theme. Can I copy, or somehow inherit, the CSS properties from datepicker to my timepicker? I do'nt want to copy the behaviour of the class, just the CSS props.

(I've seen other timepickers out there, but I'm not really happy with any of them...)

3
  • 2
    Can't you copy the CSS that you liked and rename the class to something else? Commented Jun 2, 2010 at 14:30
  • Could you just refactor your CSS so you have some common base style that you then have overrides on? CSS is designed to be cascading: This is exactly the use case why. Commented Jun 2, 2010 at 14:31
  • It's not a possibility to just use the same class again? Commented Jun 2, 2010 at 20:33

2 Answers 2

1

This is difficult to do as CSS and HTML markup (and javascript code) are very tightly coupled together. Also the CSS requires some images (usually a big one with tens of images - css selects which portion of the big image is to be shown).

In order to inherit the css, you need also to inherit the class names and use the same in your datepicker. The datepicker has dependencies also to the core jquery.ui.css and not just the datepicker.css. So, you need to also take this into account.

Sign up to request clarification or add additional context in comments.

Comments

1

You could use jQuery to read all the required values, setting them as variables on the way:

var color = $(this).css("background-color");
var padding = $(this).css("padding");

Etc etc...

Then output them via:

$(this).css({'background-color' : color+'px', 'padding' : padding+'px'});

Does that make sense, it's not really copying the stylesheet, but it is reading the sections are appending them to another element...

Best of luck.

1 Comment

What if there are dozens of different styles?

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.