Patience while learning .css - why does the following not work in my custom.css



  • I am reading and learning about .css and this forum and project have been great. I am experimenting with using my custom.css to modify various elements of my MM project. The following example has no effect on my MM clock. Are my selectors wrong?

    #module_1_clock .time, #module_1_clock .date {
    color: #628;
    }



  • Try

    .clock .time, .clock .date {
    color: #628;
    }

    or

    .time, .date {
    color: #628;
    }



  • @Wedee Thanks, will do. I was wondering why the suggestion (source used for this) used “#module_1_…”.

    This makes more sense.



  • Yes I am unsure as well…

    Playing with custom.css last week it seemed like they were defining a name to be used elsewhere and I found I didn’t need it… Depending upon the module and if the tags are unique it appears you do not need to call the module either… .time, .date
    vs
    .clock .time, .clock .date

    I include any style I wanted to do in the same group…

    I did need it when i defined a table for a background.

    For example…

    .calendar_monthly, div#module_6_calendar_monthly table.small {
    width: 550px;
    background-color: rgba(63, 182, 236, 0.23);
    border-radius: 7px;
    padding: 10px;
    }
    .calendar, div#module_7_calendar {
    width: 550px;
    font-size: 26px;
    }

    Sorry I am not more technical on it… Just what i found worked for me last week.



  • @Wedee Interestingly “.clock.time, .clock.date” did not work. However, “.clock .time, .date” does work.

    Thanks. The learning process continues!



  • @valid8r

    The reason “.clock.time” doesn’t work is because it’s looking for an object with both classes “clock” AND “time”.

    “.clock div.time” would be correct but only to address a div with the class “time” (within an object with the class “clock” ).
    ".clock .time" would be the same, but the object doesn’t have to be a div - it could be a p (paragraph) with the class “time”
    ".clock.time" would address only objects that have both classes, not regarding their parents.

    So in your case it would be correct to write “.clock .time, .clock .date” to address both “.time” and “date” within “.clock”. Your example would address all objects with the class “date” regardless of their parents class being “clock” or not.

    Edit:
    Not to confuse you, but just to make this complete, there is another way to make sure you get the right child of a parent:
    ".clock > .time" would address “.time” only if the direct parent is “.clock”. So if it’s

    < div class=“clock” >
       < div class=“time” >

    “.time” will be addressed, but if it is

    < div class=“clock” >
       < div >
          < div class=“time” >

    “.time” is not addressed. (Just in this instance with > in between.)


Log in to reply
 

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.