Changing colours in hover links via inline CSS

77 views
Skip to first unread message

Kate Simpson

unread,
Oct 31, 2013, 5:28:03 PM10/31/13
to twee...@googlegroups.com
I'd like to have a bunch of links in the same passage, each with a different hover-colour. Is this possible to do, eg. via inline @@---@@ methods, like you can with normal text colours, etc?

thanks!

HarmlessTrouble

unread,
Nov 1, 2013, 12:29:10 PM11/1/13
to twee...@googlegroups.com
Each internal link has an id string equal to the passage it links to.  You can make a stylesheet passage and target each link by passage name.

For Example a passage with the title "My Awesome Passage"

Should have the css id selector

#MyAwesomePassage


However the insertElement function is missing a step required to eliminate spaces from element ids.  So passages with spaces in the titles would not have targetable id selectors.

Heres a fix.  Create a passage tagged "script" and add the code below.
window.oldInsertElement = window.insertElement;
window.insertElement = function(a,d,f,c,e){
var b = window.oldInsertElement.apply(this, arguments);
b.id = b.id.replace(/ /g,"");
return b
};

This will eliminate spaces in ids generated by twine.

Kate Simpson

unread,
Nov 1, 2013, 12:34:28 PM11/1/13
to twee...@googlegroups.com
That's useful to know, but won't that change the colour of all links in that passage? I'm trying to get different colours within the same passage.

Kate Simpson

unread,
Nov 1, 2013, 12:35:33 PM11/1/13
to twee...@googlegroups.com
I guess I could make separate passages and trigger them via <<display>> so they appeared to be all one passage...

HarmlessTrouble

unread,
Nov 1, 2013, 12:36:46 PM11/1/13
to twee...@googlegroups.com
hmm we could ad classes too I guess. That way the same link can be targeted more than once on a page.

window.oldInsertElement = window.insertElement;
window.insertElement = function(a,d,f,c,e){
     var b = window.oldInsertElement.apply(this, arguments);
     b.id = b.id.replace(/ /g,"");
     b.class = b.class +" "+b.id;
return b
};


HarmlessTrouble

unread,
Nov 1, 2013, 12:51:39 PM11/1/13
to twee...@googlegroups.com
The ids of the link is equal to the id of the passage it links to not the passage the link is displayed in.  Each link within a passage will have a different id depending on where it goes. 

Kate Simpson

unread,
Nov 1, 2013, 12:53:04 PM11/1/13
to twee...@googlegroups.com


On Friday, 1 November 2013 16:51:39 UTC, HarmlessTrouble wrote:
The ids of the link is equal to the id of the passage it links to not the passage the link is displayed in.  Each link within a passage will have a different id depending on where it goes. 

RIGHT, sorry, I get you. Thanks, I'll try it!

Kate Simpson

unread,
Apr 25, 2014, 6:36:28 AM4/25/14
to twee...@googlegroups.com
Thread necromancy, but I only just got round to trying this, and I can't make it work, probably due to my limited grasp of the syntax. I had this in the script passage (with "attack1", etc being the passage names):

#attack1 #attack2 #attack3 #attack4 li a:hover {
  font-family: "GiveYouGlory" !important;
  color: #FF3399 !important;
   
}

but I'm not seeing anything altered ingame. Am I missing something? Am on twine 1.4.1


On Friday, 1 November 2013 16:51:39 UTC, HarmlessTrouble wrote:

Richard Sharpe

unread,
Apr 27, 2014, 5:23:04 PM4/27/14
to twee...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages