Read the statement by Michael Teeuw here.
Is there a way . . .
-
. . . to change the margins for the entire screen? If, for instance, I wanted to make the margins around the entire screen 20 pixels so that the modules would all move to the margins, how would I do that? I think it’s in one of the css files, but which one? And what code would I be looking for to edit?
And, if you are feeling very generous, how would align these two modules? Notice how the Calendar module is a bit further left than the NetworkScanner module below it?

Many thanks to all those that have already given me assistance. I’ve been trying to repay your kindness by helping others that are newer than me and are asking the questions that I asked just a few weeks ago
-
@Mykle1 put that in custom.css
body { margin: 20px; height: calc(100% - 40px); width: calc(100% - 40px); } -
@strawberry-3.141 said in Is there a way . . .:
put that in custom.css
You, Sir, are an absolute GENIUS! Absolutely PERFECT!
Many thanks!
-
"You, Sir, are an absolute GENIUS! Absolutely PERFECT!
Many thanks!"
+1 I just did the same, and screen estate looks a lot better now :-)
I’ve started today making a folder and every time I see a great tip like this, I screenshot it, name it as the tip, and place into folder. ;-) -
@johnnyboy Yeah, that one’s a keeper
-
@strawberry-3-141 Just found this, bless you. Should be in the magic mirror documentation.
-
@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); }vhstands for Viewport Height, similarlyvwstands 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 of1vwis equal to 1% of the viewport’s width,33vhis equal to 33% of the viewport’s height, etc.vwandvhare especially useful when you want to scale elements relative to the available screen space. -
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);
} -
@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
marginis 0px, there’s no need to subtract anything from the height and width - they could just be100vhand100vwrespectively. -
:root { --body-margin : 20px; } body { margin: var(--body-margin); width: calc(100vw - var(--body-margin) * 2); height: calc(100vh - var(--body-margin) * 2); } -
@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%
-
@sean Can you explain your body code a bit? I’m not quite following it.
-
@bkeyport
In modern CSS, you can usevariables. If you are using values referenced frequently or dependently, you can set that value as variables.
In prior example,--body-marginis defined. Now you can use it instead static fixed value20px. So when you have to change that value, just modify--body-marginonce. -
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?
-
@bkeyport
Yes. you are right.
Just one point, user-defined property should be start with--not- -
@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
-
@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?
-
@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. -
@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
bodyheight that’s 10px smaller than the window height). If you set the body height to be100vhand 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.
-
@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.
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