Howdy, Stranger!

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

Passage-name CSS class

Can I use the name of a passage as class to style, as example, a custom starting screen, like the classic "SEEEEGAAA" screen? Or to check if is the first passage? Or any idea to achieve this?

Comments

  • You need to state which Story Format you are using when you as a question, as answers can be different for each one.

    SugarCube assigns an ID to HTML element generated to display the contents of the current passage, this ID is based on the passage's Name and can be used in a CSS selector to style that passage.
  • Oh sorry, Harlowe. I found a way with jquery, pretty weird but working:
    <style>#sign{color:white;text-align:center}</style>
    <div id="sign">ABC</div>
    
    <script>
    $(function() {
        if($("#sign").length) {
           $('body').parent().css( "background", "black" );
        }
    });</script>
    

    This way I can assign styles before the CSS stylesheet to any element (since I have another rules for body out of the "sign" screen.
  • That is an 'interesting' way to achieve the result you wanted.

    Have you read the Basic Harlowe Passage Tag Based Styling thread, it may give you ideas on other less messy ways to do what you want like using header and footer tagged passages to effect the current passage being shown.
  • Yes, I'm using header to load a top menu, so I'd need to write more stuff to hide it on the "sega" screen. Sure it's a thing to try sometime...
Sign In or Register to comment.