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.

    Is there a way . . .

    Scheduled Pinned Locked Moved Troubleshooting
    23 Posts 8 Posters 10.1k Views 8 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.
    • Mykle1M Offline
      Mykle1 Project Sponsor Module Developer @johnnyboy
      last edited by

      @johnnyboy Yeah, that one’s a keeper

      Create a working config
      How to add modules

      1 Reply Last reply Reply Quote 1
      • BKeyportB Offline
        BKeyport Module Developer @strawberry 3.141
        last edited by

        @strawberry-3-141 Just found this, bless you. Should be in the magic mirror documentation.

        The "E" in "Javascript" stands for "Easy"

        1 Reply Last reply Reply Quote 0
        • J Offline
          j.e.f.f Project Sponsor Module Developer @strawberry 3.141
          last edited by

          @strawberry-3-141 said in Is there a way . . .:

          @Mykle1 put that in custom.css

          body {
            margin: 20px;
            height: calc(100% - 40px);
            width: calc(100% - 40px);
          }
          

          Might I suggest a small change… 100% can be interpreted by the browser in unexpected ways under certain circumstances. Sometimes when you specify 100% for height, the browser interprets this to mean 100% of the width. This is a safer way to do it:

          body {
            margin: 20px;
            height: calc(100vh - 40px);
            width: calc(100vw - 40px);
          }
          

          vh stands for Viewport Height, similarly vw stands for Viewport Width. Viewport width and height refer to the browser window’s interior size, or in the case of an iFrame, the iFrame’s interior size – essentially the space in which the HTML DOM is visible. A value of 1vw is equal to 1% of the viewport’s width, 33vh is equal to 33% of the viewport’s height, etc.

          vw and vh are especially useful when you want to scale elements relative to the available screen space.

          1 Reply Last reply Reply Quote 2
          • BKeyportB Offline
            BKeyport Module Developer
            last edited by BKeyport

            dang. For some reason, that brings it even tighter to the edges than %. Weird.

            I highly recommend the following for use on the official 7" touchscreen display. Gets you the maximum screen usage.

            (I have a mini-display magic mirror for work.) :)

            body {
            margin: 0px;
            height: calc(100vh - 10px);
            width: calc(100vw - 5px);
            }

            The "E" in "Javascript" stands for "Easy"

            michael5rM 1 Reply Last reply Reply Quote 0
            • michael5rM Offline
              michael5r Module Developer @BKeyport
              last edited by

              @bkeyport said in Is there a way . . .:

              dang. For some reason, that brings it even tighter to the edges than %. Weird.

              I highly recommend the following for use on the official 7" touchscreen display. Gets you the maximum screen usage.

              (I have a mini-display magic mirror for work.) :)

              body {
              margin: 0px;
              height: calc(100vh - 10px);
              width: calc(100vw - 5px);
              }

              If your margin is 0px, there’s no need to subtract anything from the height and width - they could just be 100vh and 100vw respectively.

              BKeyportB 1 Reply Last reply Reply Quote 0
              • ? Offline
                A Former User
                last edited by A Former User

                :root {
                  --body-margin : 20px;
                }
                
                body {
                  margin: var(--body-margin);
                  width: calc(100vw - var(--body-margin) * 2);
                  height: calc(100vh - var(--body-margin) * 2);
                }
                
                BKeyportB 1 Reply Last reply Reply Quote 1
                • BKeyportB Offline
                  BKeyport Module Developer @michael5r
                  last edited by

                  @michael5r Actually, if I don’t subtract, the margins run clear off the right side and bottom of the screen, using the official 7" touchscreen, those subtractions bring it back to 100%

                  The "E" in "Javascript" stands for "Easy"

                  1 Reply Last reply Reply Quote 0
                  • BKeyportB Offline
                    BKeyport Module Developer @Guest
                    last edited by

                    @sean Can you explain your body code a bit? I’m not quite following it.

                    The "E" in "Javascript" stands for "Easy"

                    ? 1 Reply Last reply Reply Quote 0
                    • ? Offline
                      A Former User @BKeyport
                      last edited by

                      @bkeyport
                      In modern CSS, you can use variables. If you are using values referenced frequently or dependently, you can set that value as variables.
                      In prior example, --body-margin is defined. Now you can use it instead static fixed value 20px. So when you have to change that value, just modify --body-margin once.

                      1 Reply Last reply Reply Quote 0
                      • BKeyportB Offline
                        BKeyport Module Developer
                        last edited by

                        This is the part that’s getting me…

                        width: calc(100vh - var(–body-margin) * 2);
                        height: calc(100vw - var(–body-margin) * 2);

                        If I’m reading this correctly - it’s taking the calculation of 100% of the viewpoint(direction) - the margin defined in the varible multiplied by 2?

                        100% of the viewport height minus 40 pixels in your example?

                        The "E" in "Javascript" stands for "Easy"

                        ? S 2 Replies Last reply Reply Quote 0
                        • ? Offline
                          A Former User @BKeyport
                          last edited by

                          @bkeyport
                          Yes. you are right.
                          Just one point, user-defined property should be start with -- not -

                          1 Reply Last reply Reply Quote 0
                          • S Do not disturb
                            sdetweil @BKeyport
                            last edited by

                            @bkeyport margin is both sides, or top and bottom. All the way around.

                            If u look at the original the width is hard coded at 100%- 2 times the margin value

                            Sam

                            How to add modules

                            learning how to use browser developers window for css changes

                            1 Reply Last reply Reply Quote 0
                            • BKeyportB Offline
                              BKeyport Module Developer
                              last edited by

                              @sdetweil so, then because I have to use the following:

                              body {
                              margin: 0px;
                              height: calc(100vh - 10px);
                              width: calc(100vw - 5px);
                              }
                              

                              am I correct in assuming that magicmirror sees the screen a few pixels bigger than it really is - and that’s being expressed by running off the right and bottom of the screen when I don’t have the 10px subtract from height, and the 5px subtract from width?

                              The "E" in "Javascript" stands for "Easy"

                              S michael5rM 2 Replies Last reply Reply Quote 0
                              • S Do not disturb
                                sdetweil @BKeyport
                                last edited by

                                @bkeyport I also had a heck of a time modifying body to get a fullscreen image.
                                I finally changed to use the .fullscreen.above css setting. I was also worried that if I required body to be changed and some else’s module also required body changed, then the conflict would mess up my display.

                                Sam

                                How to add modules

                                learning how to use browser developers window for css changes

                                1 Reply Last reply Reply Quote 0
                                • michael5rM Offline
                                  michael5r Module Developer @BKeyport
                                  last edited by

                                  @bkeyport said in Is there a way . . .:

                                  @sdetweil so, then because I have to use the following:

                                  body {
                                  margin: 0px;
                                  height: calc(100vh - 10px);
                                  width: calc(100vw - 5px);
                                  }
                                  

                                  am I correct in assuming that magicmirror sees the screen a few pixels bigger than it really is - and that’s being expressed by running off the right and bottom of the screen when I don’t have the 10px subtract from height, and the 5px subtract from width?

                                  No - the screen is the size it is.

                                  Your CSS above doesn’t make sense (you’re setting a body height that’s 10px smaller than the window height). If you set the body height to be 100vh and you get a vertical scrollbar, it’s because of another margin that’s pushing the body element.

                                  In general, it’s good practice to also do:

                                  html {
                                      margin: 0;
                                      padding: 0;
                                  }
                                  

                                  to avoid situations like this.

                                  BKeyportB 1 Reply Last reply Reply Quote 0
                                  • BKeyportB Offline
                                    BKeyport Module Developer @michael5r
                                    last edited by

                                    @michael5r - Actually, I don’t get scrollbars at all. If I don’t subtract back from the 100vh/100vw or 100% - It’ll just run off the edge of the screen as if the system is seeing the screen (In this case, the RasPi’s 7" touchscreen) bigger than it is. With it set the way I have it, everything is dead on edge, giving the maximum use of the screen.

                                    The "E" in "Javascript" stands for "Easy"

                                    michael5rM 1 Reply Last reply Reply Quote 0
                                    • michael5rM Offline
                                      michael5r Module Developer @BKeyport
                                      last edited by

                                      @bkeyport said in Is there a way . . .:

                                      @michael5r - Actually, I don’t get scrollbars at all. If I don’t subtract back from the 100vh/100vw or 100% - It’ll just run off the edge of the screen as if the system is seeing the screen (In this case, the RasPi’s 7" touchscreen) bigger than it is. With it set the way I have it, everything is dead on edge, giving the maximum use of the screen.

                                      I’m glad it works for you, but it still doesn’t make any sense :)

                                      J 1 Reply Last reply Reply Quote 0
                                      • J Offline
                                        j.e.f.f Project Sponsor Module Developer @michael5r
                                        last edited by

                                        @michael5r the CSS is also set to hide overflow on the body so even if the CSS defines a screen size larger than 100% you won’t get scroll bars. You’ll just get the contents pushing off screen or at least not centred.

                                        michael5rM 1 Reply Last reply Reply Quote 0
                                        • michael5rM Offline
                                          michael5r Module Developer @j.e.f.f
                                          last edited by

                                          @j-e-f-f Sure, that’s the magic of the overflow: hidden style. But what puzzles me is this:

                                          An example:
                                          If you run a webpage in fullscreen mode (either through Electron using Chromium or in a regular browser), and style the body like this:

                                          body {
                                              background-color: #333;
                                              width: 100vw;
                                              height: 100vh;
                                              padding: 0;
                                              margin: 0;
                                              overflow: hidden;
                                          }
                                          

                                          you will have a grey area that takes up the entire width & height of your screen.

                                          If, on the other hand, you styled the body tag like this:

                                          body {
                                              background-color: #333;
                                              width: calc(100vw-10px);
                                              height: calc(100vh-10px);
                                              padding: 0;
                                              margin: 0;
                                              overflow: hidden;
                                          }
                                          

                                          you will have a grey area that is 10px shorter and narrower than the available screen space.

                                          The only reason this wouldn’t be the case is if the html tag has a margin or padding (which would restrict the amount of space available to the body tag) or if you’ve specified a specific screen size directly in Electron (using electronOptions.width and electronOptions.height).

                                          It’s no different than the standard body styles defined in MagicMirror’s main.css file - in there, a margin of 60px is set and then the height & width are set with width: calc(100%-120px) and height: calc(100%-120px) respectively.

                                          1 Reply Last reply Reply Quote 0

                                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                          With your input, this post could be even better 💗

                                          Register Login
                                          • 1
                                          • 2
                                          • 1 / 2
                                          • 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