Forums

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

Home Forums CSS CSS if Condition Statements

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #259373
    Sam1234
    Participant

    Hi,

    I am trying to find a way to target a using only css.

    If there are 2 selects showing i want to give it a different css style compared to if there is only 1 showing.

    Any ideas how to do this?

    Here is my HTML:

    <form>
                            <select id="itemType" class="medium">
                                <?php include $root.$path.'includes/itemType.php'; ?>
                            </select>
    
                            <select id="title" class="medium">
                                <?php include $root.$path.'includes/title.php'; ?>
                            </select>
    
    </form>
    
    #259375
    Paulie_D
    Moderator

    There is no such thing

    CSS is not conditional except the selector applies or it doesn’t.

    However…

    If there are 2 selects showing i want to give it a different css style compared to if there is only 1 showing.

    It depends on what you mean by “showing”…if you mean there is only one in the DOM parent element then it is possible. If you mean the are both there but only one is *visible** then it’s not.

    You could use the :only-of-type selector to style the select when there is only one.

    https://codepen.io/Paulie-D/pen/NvMYyr

    #259386
    Sam1234
    Participant

    Hi, thanks for the reply.

    I have multiple pages.

    some have tag twice on them and some only have it once. The same style sheet is linked to all of the pages.

    The :only-of-type tag looks useful. I will have a look into that

    Thanks

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