• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Modifying Stylesheet (Weathermap, News feed & Temperature)

Scheduled Pinned Locked Moved Custom CSS
4 Posts 3 Posters 3.3k Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    werdnllac
    last edited by Feb 24, 2018, 7:33 AM

    Hi all, I am new here and had benefited from the forum building my first magic mirror.

    I had a default magic mirror built and would like to modify the style sheet, changing the font size and colour.

    Can anyone share how to get it done?

    Appreciate for your advice.

    1 Reply Last reply Reply Quote 0
    • D Offline
      doubleT Module Developer
      last edited by Feb 24, 2018, 4:49 PM

      My advice is to check both files in MagicMirror/css/: main.css and custom.css.
      In main.css you can see all default css, don’t change anything but you can learn a lot. When you identify what you want to change, copy it in main.css, paste it into custom.css and make the changes.

      For css, it’s relevant when something is loaded. If an identifier with a style is mentioned two times in a file, the second one overwrites the first one. And custom.css is loaded after main.css, so styles there override main.css.

      Here’s how to get started with css: https://www.w3schools.com/css/

      Also, you might want to check out the browsers developer tools. Start the mirror with npm start dev and you can select the elements, learn about their identifiers, classes, IDs and you can test changes directly in these developer tools (non permanent).

      W J 2 Replies Last reply Feb 24, 2018, 5:15 PM Reply Quote 0
      • W Offline
        werdnllac @doubleT
        last edited by Feb 24, 2018, 5:15 PM

        @doubleT Thank you. I manage to get the stylesheet.

        1 Reply Last reply Reply Quote 0
        • J Offline
          j.e.f.f Project Sponsor Module Developer @doubleT
          last edited by j.e.f.f Mar 19, 2018, 6:55 PM Mar 19, 2018, 6:54 PM

          @doubleT said in Modifying Stylesheet (Weathermap, News feed & Temperature):

          For css, it’s relevant when something is loaded. If an identifier with a style is mentioned two times in a file, the second one overwrites the first one. And custom.css is loaded after main.css, so styles there override main.css.

          Not quite accurate, and this can lead to some confusion. The second rule will take precedence over the first if they are equally specific, or if the second rule is more specific that the first. A more specific rule will always take precedence over a less specific rule, not matter what order they appear to the system.

          Here are some examples:

          .module-content {
            width: 150px;
          }
          
          ...
          
          .module-content {
            width: 300px;
          }
          
          /*
            exactly the same specificity, 2nd rule takes precedence,
            and anything with the class .module-content will be
            sized to 300px wide
          */
          
          

          Another example:

          .region.top.left .module-content {
            width: 150px;
          }
          
          ...
          
          .module-content {
            width: 300px;
          }
          
          /*
            First rule is more specific. Any element with the class .module-content
            within an element with the classes .region.top.left will be sized to
            150px wide. Any other element with the class .module-content
            will be sized to 300px.
          
            for example, here is some markup:
          
            < div class="region top right" >
              < div class="module-content" >
                This will be sized to 300px
              < /div>
            < /div>
          
            < div class="region top left" >
              < div class="module-content" >
                This will be sized to 150px
              < /div>
            < /div>
          
          */
          
          

          Lastly, any rule with the !important flag will take precedence regardless of specificity.

          Example:

          .region.top.left .module-content {
            width: 150px;
          }
          
          ...
          
          .module-content {
            width: 300px !important;
          }
          
          /*
            Any element with the class .module-content will be
            sized to 300px. The !important flag takes precedence
            over the more specific rule above it.
          */
          
          

          Try not to never use the !important flag. This makes it much harder to override your rule later if you decide you need to. Instead, if you are finding that your rule is not taking effect, it is most likely due to a more specific rule taking precedence. The real solution is to write a more specific rule to make yours take precedence.

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Sam, technical setup by Karsten.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy