Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS .focus and :focus

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #186314
    sakii
    Participant

    Hi,

    This been buzzing me.

    #id .class .class2 input[type=”submit”] {
    opacity: 0;
    }
    #id .class.focus .class2 input[type=”submit”] {
    opacity: 1;
    }

    Why does this is able to change the opacity to 1 when i click onto the text input box ? When we should use :focus instead ?

    #186316
    Paulie_D
    Member

    .focus is a class that could do anything.

    :focus is a pseudo-class that is applied when a element has received focus, either from the user selecting it with the use of a keyboard or by activating with the mouse (e.g. a form input).

    #186318
    sakii
    Participant

    hmm but in the whole css i don’t find any .focus class. but somehow it worked like when the text input was focus , the opacity of submit input will become 1.

    Is this the work of javascript ?

    #186321
    __
    Participant

    Is this the work of javascript ?

    That’s possible, but there’s no way we could know. Is there any javascript on your page that uses the classname “focus”?

    hmm but in the whole css i don’t find any .focus class

    Do you mean, in your html?

    CSS has a class selector, but the classes (classnames) themselves are declared in your html.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.