Any known way to differentiate CSS based on whether the user is part of the game?

Abersade
Abersade

Afternoon folks,

This has likely been asked before but it's been awhile as far as I can recall, I'm hoping someone better than I am at CSS already knows of a method. What I'm looking to do is to customize the CSS for one of my sites based on whether or not the person viewing the screen is one of the players in the game.

The reason I want to do this is because of the navigation bar differences between users that are players in the game and everyone else, I'd really like to be able to fix the spacing of the navbar titles for everyone but the players.

Image example below showing the issue, also a good illustration of how different browsers render images a bit differently. Left is Firefox, right is Chrome.

image

GM of Rise of the Durnskald: Wrath of the Fallen Goddess - February 2016 CotM

GM of Core: The Ashes of Alcarna - April 2020 CotM

GM of Stream of Kairos

Need CSS Help? It may be covered here: Abersade's CSS Hub

Comments

  • ragnarhawk
    Posts: 168 edited February 2022

    Yes, I have done something like this.  The restricted sections are still there in the html, but are hidden by the CSS.

    Here is some CSS (for campaign members):

    .MembersOnly {display: none;}
    body.campaign-member  .MembersOnly {display: revert;}
    body.campaign-member  .PublicView {display: none;}

    and the HTML (this adds text to an existing line - the class can be applied on anything from a span to a div:

    [[Main Page | Return to Main Stage ]]<span class="MembersOnly">| [[Character Creation | Character Creation]]  </span>

     You can see it in action here:  https://thecarmensandiegooperahouse.obsidianportal.com/wikis/roles

    And it is used on divs on other pages in that wiki.

    Post edited by ragnarhawk on
  • Abersade
    Abersade
    Posts: 417

    .PublicView

    Very interesting. Thanks!

    GM of Rise of the Durnskald: Wrath of the Fallen Goddess - February 2016 CotM

    GM of Core: The Ashes of Alcarna - April 2020 CotM

    GM of Stream of Kairos

    Need CSS Help? It may be covered here: Abersade's CSS Hub

  • ragnarhawk
    Posts: 168

    Note that .PublicView is also a class that you add to the html content, so the page can have Members Only sections, Public View (non members only), and general content that everyone sees

Sign In or Register to comment.

March 2024
Wrath of the Highborn

Read the feature post on the blog
Return to Obsidian Portal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions