Skip to content

Instantly share code, notes, and snippets.

@eritbh
Last active January 5, 2019 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eritbh/221e787cd8f70a6ddbc8028cf59e7120 to your computer and use it in GitHub Desktop.
Save eritbh/221e787cd8f70a6ddbc8028cf59e7120 to your computer and use it in GitHub Desktop.
/*!
* /r/anime custom page width + background userstyle/RES snippet
* by /u/geo1088
* public domain
*
* If you use this style, please don't send modmails when it breaks
* Instead, message /u/geo1088 directy:
* <https://www.reddit.com/compose?to=geo1088>
*/
/* Enter your configurations settings here */
:root {
/* Maximum width of the Reddit content */
/* MAKE SURE YOU ALSO UPDATE THIS VALUE IN THE @media SECTION BELOW or negative margins will wreck your shit */
--max-width: 1280px;
/* For no image, set this to `none` (without quotes) */
--background-image: url('https://i.ytimg.com/vi/gpV48sIOBfw/maxresdefault.jpg');
/* If you set an image, this won't show up */
--background-color: #EEE;
/* Color for the small border on the left and right of the content - to hide, set this to "transparent" without quotes */
--body-border-color: #CCC;
/* Advanced background image options */
--background-position: center;
--background-size: cover;
--background-repeat: no-repeat;
--background-attachment: fixed;
}
/* This is the second place you need to set the width option from above */
/* If this is different than the entry above then bad things happen */
/* (yes, it says max-width in one place and min-width in another, that's correct) */
@media screen and (min-width: 1280px) {
/* If you don't know CSS this is where you should stop editing */
/* Some variables we only need now */
:root {
--header-height: 115px;
--tabbar-height: 35px;
--margin-width: calc(50vw - var(--max-width) / 2);
--margin-width-plus-one: calc(var(--margin-width) + 1px);
}
/* Recenter header */
#header {
position: relative;
width: 100vw;
left: 50%;
transform: translateX(-50%);
}
/* Extend the tab menu "fins" */
/* Strange one-off offsets to prefent stuttering on the edge of the viewport */
#header::before,
#header::after {
content: "";
display: block;
position: absolute;
top: calc(var(--header-height) - var(--tabbar-height));
left: -1px;
width: var(--margin-width-plus-one);
height: 35px;
background: #557eb8;
}
#header::after {
left: unset;
right: -1px; /* this is the line that makes us need overflow-x: hidden; on html */
}
/* Move the tab bar and stuff back to the center */
#header-bottom-left,
#header-bottom-right,
#RESShortcutsEditContainer {
margin-left: var(--margin-width);
margin-right: var(--margin-width);
}
#sr-header-area {
padding-left: var(--margin-width);
padding-right: var(--margin-width);
}
}
/* These guys are outside the media query because they don't deal with weird margins */
html {
/* since :root is the HTML element this is kinda unnecessary but it makes the config consistent lol */
background-image: var(--background-image);
background-size: var(--background-size);
background-position: var(--background-position);
background-attachment: var(--background-attachment);
background-repeat: var(--background-repeat);
overflow-x: hidden; /* see #header::after */
}
body {
max-width: var(--max-width);
margin: 0 auto;
position: relative;
box-shadow: 0 0 0 1px var(--body-border-color);
}
/*!
* /r/anime custom page width + background userstyle/RES snippet
* by /u/geo1088
* public domain
*
* If you use this style, please don't send modmails when it breaks
* Instead, message /u/geo1088 directy:
* <https://www.reddit.com/compose?to=geo1088>
*/
/* Enter your configurations settings here */
:root {
/* Maximum width of the Reddit content */
/* MAKE SURE YOU ALSO UPDATE THIS VALUE IN THE @media SECTION BELOW or negative margins will wreck your shit */
--max-width: 1280px;
/* For no image, set this to `none` (without quotes) */
--background-image: url('https://i.ytimg.com/vi/gpV48sIOBfw/maxresdefault.jpg');
/* If you set an image, this won't show up */
--background-color: #EEE;
/* Color for the small border on the left and right of the content - to hide, set this to "transparent" without quotes */
--body-border-color: #CCC;
/* Advanced background image options */
--background-position: center;
--background-size: cover;
--background-repeat: no-repeat;
--background-attachment: fixed;
}
/* This is the second place you need to set the width option from above */
/* If this is different than the entry above then bad things happen */
/* (yes, it says max-width in one place and min-width in another, that's correct) */
@media screen and (min-width: 1280px) {
/* If you don't know CSS this is where you should stop editing */
/* Some variables we only need now */
:root {
--header-height: 115px;
--tabbar-height: 35px;
--margin-width: calc(50vw - var(--max-width) / 2);
--margin-width-plus-one: calc(var(--margin-width) + 1px);
}
/* Recenter header */
#header {
position: relative;
width: 100vw;
left: 50%;
transform: translateX(-50%);
}
/* Extend the tab menu "fins" */
/* Strange one-off offsets to prefent stuttering on the edge of the viewport */
#header::before,
#header::after {
content: "";
display: block;
position: absolute;
top: calc(var(--header-height) - var(--tabbar-height));
left: -1px;
width: var(--margin-width-plus-one);
height: 35px;
background: #557eb8;
}
#header::after {
left: unset;
right: -1px; /* this is the line that makes us need overflow-x: hidden; on html */
}
/* Move the tab bar and stuff back to the center */
#header-bottom-left,
#header-bottom-right,
#RESShortcutsEditContainer {
margin-left: var(--margin-width);
margin-right: var(--margin-width);
}
#sr-header-area {
padding-left: var(--margin-width);
padding-right: var(--margin-width);
}
}
/* These guys are outside the media query because they don't deal with weird margins */
html {
/* since :root is the HTML element this is kinda unnecessary but it makes the config consistent lol */
background-image: var(--background-image);
background-size: var(--background-size);
background-position: var(--background-position);
background-attachment: var(--background-attachment);
background-repeat: var(--background-repeat);
overflow-x: hidden; /* see #header::after */
}
body {
max-width: var(--max-width);
margin: 0 auto;
position: relative;
box-shadow: 0 0 0 1px var(--body-border-color);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment