Border colour based on character tags

Hoob
Hoob
edited June 2015 in Campaign Portal Building
Is it possible to apply custom CSS styles to character listings based on their tags, or some workaround to achieve the same effect?

This is my character page: https://bloodandstone.obsidianportal.com/characters

Currently I've got the various noble houses in my game sorted by using different unicode whitespace charactres in front of their names. That works fine for keeping things in order, but what I'd really like to do is have a custom border colour for each group, to make the distinction more obvious. Is there any way to do this?

Comments

  • Bortas
    Bortas
    Posts: 645
    Not cleverly, unfortunately, I've tried so many ways to do that. However, you can manually do it for each character via CSS:
    @.game-content-image[title="EXACT CHARACTER NAME"] + .character-info {
    border-color: blue; /* what color border should be */
    border:4px solid; /* how bold border should be */
    }@

    And for each character you want to change the border of, you do an entry exactly like above. Fun, huh? ;-)

    I really hope someone else answers with a far more elegant solution..., but I doubt it exists without having to access database information, which CSS doesn't do.

    In the "Tales of..." campaign I'm working on below, you can see we put a yellow border around PCs, to make them stand out from NPCs, and it is only one CSS statement. But as far as CSS and character page, you have 3 options: PC, NPC and GM only.

    -bort
    "Morwindl":https://morwindl.obsidianportal.com - first and only campaign I've DM'd (first experience with CSS)
    "Tales of...":https://talesof.obsidianportal.com - campaign I'm helping a friend design the layout for
  • UselessTriviaMan
    UselessTriviaMan
    Posts: 546
    I wish I were able to offer assistance, but I just popped in to compliment you on a great Characters page. How did you apply different colors to the House tags like that?

    (I'm, uh, asking for a friend. Yeah, that's it. I totally won't steal it. Much.) ;-)

    Ptolus, City by the Spire - 2016 Campaign of the Year

    "Please pay attention very carefully, because this is the truest thing a stranger will ever say to you: In the face of such hopelessness as our eventual, unavoidable death, there is little sense in not at least TRYING to accomplish all your wildest dreams in life."  - - Kevin Smith

  • Abersade
    Abersade
    Posts: 420 edited June 2015
    @Useless TriviaMan

    This is what I use.

    /* TAGS */
    /* Color Coded Tagging */
    /* use these lines to change the font color and background color*/
    /* data-tag= is the tag (case sensitive), background-color: is the "bubble" color around the tag text, color: is the color of the tag text */
    .campaign-public-layout #content a[data-tag="player"] {background-color: #365BCE;color: #ffffff;-webkit-border-radius:1000px;border-radius:1000px;padding:0.1875em 0.625em 0.25em;font-size:0.875em;}
    .campaign-public-layout #content a[data-tag="captured"] {background-color: #f9bd37;color: #ffffff;-webkit-border-radius:1000px;border-radius:1000px;padding:0.1875em 0.625em 0.25em;font-size:0.875em;}
    .campaign-public-layout #content a[data-tag="enemy"] {background-color: #c60f13 ;color: #ffffff;-webkit-border-radius:1000px;border-radius:1000px;padding:0.1875em 0.625em 0.25em;font-size:0.875em;}
    .campaign-public-layout #content a[data-tag="deceased"] {background-color: #2E2E2E;color: #E6E6E6;-webkit-border-radius:1000px;border-radius:1000px;padding:0.1875em 0.625em 0.25em;font-size:0.875em;}
    .campaign-public-layout #content a[data-tag="ally"] {background-color: #0B0B61;color: #F5F6CE;-webkit-border-radius:1000px;border-radius:1000px;padding:0.1875em 0.625em 0.25em;font-size:0.875em;}
    .campaign-public-layout #content a[data-tag="ARC"] {background-color: #0B0B61;color: #F5F6CE;-webkit-border-radius:1000px;border-radius:1000px;padding:0.1875em 0.625em 0.25em;font-size:0.875em;}
    .campaign-public-layout #content a[data-tag="Durnskald"] {background-color: #000000;color: #FF0000;-webkit-border-radius:1000px;border-radius:1000px;padding:0.1875em 0.625em 0.25em;font-size:0.875em;}
    .campaign-public-layout #content a[data-tag="Tsochar"] {background-color: #8000FF;color: #01DFA5;-webkit-border-radius:1000px;border-radius:1000px;padding:0.1875em 0.625em 0.25em;font-size:0.875em;}

    This page is what it looks like: https://rise-of-the-durnskald.obsidianportal.com/characters
    If you don't want the bubble of color around the tag, omit the "background-color: #0B0B61;" part.
    Post edited by Abersade on

    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

  • Abersade
    Abersade
    Posts: 420
    Also, that's awesome Bort. I've been trying to get that to work for the last 2 hours but I couldn't figure out how to target the character listing specifically.

    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

  • MachineGunHarry
    MachineGunHarry
    Posts: 115
    Bortas,

    Here is some code that I remember Basileus using to alter the text color of the actual tags:

    @.character-index.campaign-public-layout #content a[data-tag="PC"] {color: springgreen; font-weight: bold;}
    .character-index.campaign-public-layout #content a[data-tag="Deceased"] {color: firebrick; font-weight: bold;}@

    There maybe a way to use parts of this code, combined with your code to isolate specific groups classified by their TAGS, rather than their image name. Play around with it a bit to see what you could create.
  • Bortas
    Bortas
    Posts: 645
    MGH - I really REALLY want it to work... but the only way my brain sees around this issue is with something like an "IF" statement, which CSS doesn't use. Any other brains chewing on this one?

    -bort
    "Morwindl":https://morwindl.obsidianportal.com - first and only campaign I've DM'd (first experience with CSS)
    "Tales of...":https://talesof.obsidianportal.com - campaign I'm helping a friend design the layout for
  • Unknown
    I am pretty out of it right now, but just looking over this I feel like there is probably a way to accomplish this via the use of Tags on the characters. Give me a bit to get myself thinking about this more clearly and see if I can't come up with something that can achieve the desired results.
  • Hoob
    Hoob
    Posts: 4
    Thanks for the tips everyone.

    Ended up using Bortas' method to manually apply borders to each character, had the desired effect, even if it was a little tedious : https://bloodandstone.obsidianportal.com/characters

    But now I've got another question on the matter: the borders seem to render on a layer below the character portraits on both browsers I've tried. Is there anyway to change that? I'd like the borders over the portrait if possible, but it's hardly a huge issue.

    I pastebinned my CSS in case it helps any. http://pastebin.com/PLVJFrsy
  • MachineGunHarry
    MachineGunHarry
    Posts: 115
    You need to set the item's z-index higher. So added in "z-index:10;" or so. Even this might not be high enough. So keep changing the number after z-index, until it is right.
  • Hoob
    Hoob
    Posts: 4
    Thanks heaps, that fixed it. Looks perfect now!
  • Unknown
    Well, that saves me looking into this then. Glad you have things working as desired.
  • MachineGunHarry
    MachineGunHarry
    Posts: 115
    Wait, alex_redeye! If you can come up with a way to blend the above information, that's the golden goose here. In other words, isolating how to use the data-tag to change the game-content-image style sheet.
  • Unknown
    Fair enough, give me a bit of time to chew this over. The main trick with this is going to be the fact that there is no parent selector in CSS (including CSS3) and there are some valid reasons for the lack of existence in present WebKits. Now, with that said, a bit of finagling might still be able to accomplish this. My initial sentiment is that the > selector might still be able to accomplish this, but I am going to have to do some extensive review of the code layout on OP for those pages.

    Looks like I need to build myself a testing campaign to fiddle with some concepts like this. I'll get back to everyone soon if I manage to find some kind of solution to this that doesn't require writing up CSS for every single character that a campaign has (since I view that solution as very poorly setup due to the level of clutter this will generate in the CSS file which will in time have an impact on page load times).
  • MachineGunHarry
    MachineGunHarry
    Posts: 115
    Could the answer be to turn the existing class that uses the character's image to "display:none", then building a new class that can be activated using the data-tag information?
Sign In or Register to comment.

April 2024
Season of Strife

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