Pamasich,
@Pamasich@kbin.social avatar

Okay, so I've created a magazine and tested some stuff out.

In the first code I posted, I used the child selector (>) to select <header> elements directly inside <main> elements. For some reason, custom CSS doesn't seem to support the child selector. No matter where I try to use it, the style isn't applied.

The following code worked for me on my magazine:

main header:has(h1[hidden]) {
    height: 300px;
    background-image: url(https://i.imgur.com/wbZa4eI.png);
    background-size: 100% auto;
    background-position-y: -150px;
}

I removed the child selector and instead used :has(hi1[hidden]) to make sure I only get the target element. Without it, it would also replace the background of the individual thread titles.

The image you're trying to use is a bit large, so I've included an example usage of background-size and background-position to change the size of the image and what part of it actually gets displayed.
With background-size, the first value is how wide the image should be, while the latter value is how high. Percentage values are relative to the element's size. So the width and height properties. You can also set absolute values, like I did with height in pixels in this example.

The big issue with this one though is that it'll only apply to the Threads and All Content views. Other views, including Microblog and individual threads, don't have the <header> element I'm looking for here.

I modified it to apply to more views:

h1[hidden] {
    height: 300px;
    background-image: url(https://i.imgur.com/wbZa4eI.png);
    background-size: 100% auto;
    background-position-y: -150px;
    display: block;
    color: transparent;
    user-select: none;
}

The last two lines are there because this actually displays the name of the magazine on the banner. Since that's kind of redundant, since it's already in the bar at the top, I'm hiding the text and making it not selectable.

This one does work in all the views I tested except for when looking at a thread and its comments.

Though, something worth considering in case you intend to just use this code as-is: I just used pixels for simplicity. But the result might look entirely different on other screen resolutions than mine. Here's a list of better units to use if you want it to look the same on all screens. You can use percentages, pixels, and these other units interchangeably anywhere.


About the second code I posted, for some reason :before, much like the child selector, doesn't seem to work. I can very much target the #middle and #header elements from custom magazine CSS, but :before doesn't do anything.

I'm not sure why this is. I see no security reason to block them, so I assume it's not intentional. It's a bit hard to debug :before specifically because I don't know any way to get its styles without making it visible. So I have no idea if something is overwriting the style or if the selector just doesn't work, like is the case with the child selector. I'll have to look into this a bit more over the weekend.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • kbinMeta@kbin.social
  • meta
  • Macbeth
  • All magazines