Tweak

InsaneJournal

Tweak says, "Life needs things to live."

Username: 
Password:    
Remember Me
  • Create Account
  • IJ Login
  • OpenID Login
Search by : 
  • View
    • Create Account
    • IJ Login
    • OpenID Login
  • Journal
    • Post
    • Edit Entries
    • Customize Journal
    • Comment Settings
    • Recent Comments
    • Manage Tags
  • Account
    • Manage Account
    • Viewing Options
    • Manage Profile
    • Manage Notifications
    • Manage Pictures
    • Manage Schools
    • Account Status
  • Friends
    • Edit Friends
    • Edit Custom Groups
    • Friends Filter
    • Nudge Friends
    • Invite
    • Create RSS Feed
  • Asylums
    • Post
    • Asylum Invitations
    • Manage Asylums
    • Create Asylum
  • Site
    • Support
    • Upgrade Account
    • FAQs
    • Search By Location
    • Search By Interest
    • Search Randomly

Ally -- are you already gone? ([info]wastintime) wrote in [info]rp_tutorials,
@ 2009-05-05 07:56:00

Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Entry tags:tools: html

[Code] The "Magic Click"

Example #1
 
 
 
click me!

Note: If this demonstration shows up as three icons in a column or clicking on the initial image does not cycle through three images in total, this HTML trick does not work in your browser. :(


CREDITS
    • Images: Jérémie Renier icons by [info]textless

RULES
    • Credit to [info]rp_tutorials. This is not absolutely necessary considering since this is not a layout code.
    • You can modify the code however you wish. Go nuts.
    • Comments are appreciated.

THE CODE 
    

HOW TO USE
    1. The images you use must all be of the same height for this code to work properly.
    2. Replace the 'IMAGE URL's with the URLs your chosen images.
    3. Replace all "height" pixel measurements (in the <div> tag and the <img> tags) with the height of your images.

  To add additional images...
    1. Copy the code for one row of the table and paste it below the last row in the table.
    2. Increment the digits in the <a> tags of the new row. The last image should always point back to the first.

EXAMPLE #2

1. Click a "Character Name" link to see a profile.
2. The "back to Game #" link at the end of a profile will return you to the game's table.
3. Notice that clicking a link in one game table does not affect the state of the other game table.
 
GAMETITLE

Character Name
Played By Name

Character Name
Played By Name

Character Name
Played By Name

Character Name
Played By Name
@ [info]gameurl




 PROFILE FOR CHARACTER #1 (OF GAME #1)
HEADLINE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin hendrerit vulputate nisl. Sed fringilla risus vestibulum purus. Nunc at lacus. Donec arcu tellus, interdum in, venenatis vitae, aliquet ac, metus. Sed fringilla ipsum vel nisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
LINK LINK LINK LINK
FOOTER TEXT | BACK TO GAME #1



 PROFILE FOR CHARACTER #2 (OF GAME #1)
HEADLINE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin hendrerit vulputate nisl. Sed fringilla risus vestibulum purus. Nunc at lacus. Donec arcu tellus, interdum in, venenatis vitae, aliquet ac, metus. Sed fringilla ipsum vel nisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
LINK LINK LINK LINK
FOOTER TEXT | BACK TO GAME #1



 PROFILE FOR CHARACTER #3 (OF GAME #1)
HEADLINE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin hendrerit vulputate nisl. Sed fringilla risus vestibulum purus. Nunc at lacus. Donec arcu tellus, interdum in, venenatis vitae, aliquet ac, metus. Sed fringilla ipsum vel nisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
LINK LINK LINK LINK
FOOTER TEXT | BACK TO GAME #1



 PROFILE FOR CHARACTER #4 (OF GAME #1)
HEADLINE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin hendrerit vulputate nisl. Sed fringilla risus vestibulum purus. Nunc at lacus. Donec arcu tellus, interdum in, venenatis vitae, aliquet ac, metus. Sed fringilla ipsum vel nisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
LINK LINK LINK LINK
FOOTER TEXT | BACK TO GAME #1





 
GAMETITLE

Character Name
Played By Name

Character Name
Played By Name

Character Name
Played By Name

Character Name
Played By Name
@ [info]gameurl




 PROFILE FOR CHARACTER #1 (OF GAME #2)
HEADLINE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin hendrerit vulputate nisl. Sed fringilla risus vestibulum purus. Nunc at lacus. Donec arcu tellus, interdum in, venenatis vitae, aliquet ac, metus. Sed fringilla ipsum vel nisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
LINK LINK LINK LINK
FOOTER TEXT | BACK TO GAME #2



 PROFILE FOR CHARACTER #2 (OF GAME #2)
HEADLINE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin hendrerit vulputate nisl. Sed fringilla risus vestibulum purus. Nunc at lacus. Donec arcu tellus, interdum in, venenatis vitae, aliquet ac, metus. Sed fringilla ipsum vel nisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
LINK LINK LINK LINK
FOOTER TEXT | BACK TO GAME #2



 PROFILE FOR CHARACTER #3 (OF GAME #2)
HEADLINE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin hendrerit vulputate nisl. Sed fringilla risus vestibulum purus. Nunc at lacus. Donec arcu tellus, interdum in, venenatis vitae, aliquet ac, metus. Sed fringilla ipsum vel nisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
LINK LINK LINK LINK
FOOTER TEXT | BACK TO GAME #2



 PROFILE FOR CHARACTER #4 (OF GAME #2)
HEADLINE
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin hendrerit vulputate nisl. Sed fringilla risus vestibulum purus. Nunc at lacus. Donec arcu tellus, interdum in, venenatis vitae, aliquet ac, metus. Sed fringilla ipsum vel nisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
LINK LINK LINK LINK
FOOTER TEXT | BACK TO GAME #2




CREDITS
    • Inspired by the cast list from [info]scandalousmods Edit: Who received their snazzy code from [info]define
    • Slighty modified game table and character profile layouts from [info]rp_tutorials.

That was all pretty nifty, eh? But what is this "magic click" code and how does it work?

THE EXPLANATION

PART 1: ANCHORS
If you understand page navigation, you can just skim this.

What They Are
Anchors and Page Navigation -- learn them, use them, make your pages easier to move through and share. They are essential to making this "magic click" business work. <a> tags, which are also known as "anchors", can either be a target or an origin.

You are likely familiar with one type of anchor, the target anchor <a href"">link</a> which creates a hyperlink. A hyperlink may link to another site, but it can also link to different points within one page.

If you've ever used links to move around in a page (e.g. Wikipedia articles) by section or even simply using a "back to top" link, then you've used page navigation. It is the origin anchor <a name=""></a> that makes page navigation possible. This type of anchor assigns a section name to a certain point within a web page.

To create a linkable section within your web page, put an origin <a name=""> anchor at the beginning of said section and give the section a name (e.g. "sect1") within the quotes. You are not required to use an anchor close tag </a> on a origin anchor and any text or code used between the opening and closing tag (i.e. <a name="sect1">text</a>) will be visible. If you dislike leaving open tags (like me) you can insert a black space <a name="sect1">&nbsp;</a>. If you use an anchor with no text whatsoever between the tags (i.e. <a name="sect1"></a>), Internet Explorer WILL ignore your section name -- so, don't do this.

In order for a link to target a section within the same page, your target anchor will be of the form <a href="#name">link</a>. The # symbol is what indicates a section name is being used. Clicking on different section links will replace what follows the # symbol in the address bar and will navigate you to the next section of the page. The # symbol should ONLY be used in the target anchor. It is not needed in the origin anchor and will cause your anchor to not work properly. You may also link to sections of different web pages by inserting the page's url in front of the # symbol <a href="URL#name">link</a>.

Examples of in-page and multi-page sectional navigation can be found here.

How They Are Used In This Code
You may have noticed that the links within the Example #1 code and the Example #2 game tables reference sections within this same page. We'll get to the logistics of why all of these other sections are hidden in a moment, but right now, take a moment to click around in the examples. Do you see the repeated use of the # symbol? Yes, all of the code for each of these linked sections is contained within this page! It's just page navigation.

If you'll look back to the code for Example #1, you should notice that each image has both a target and an origin anchor so that each click causes the page jump to the successive section (i.e. the image, in this case) in the order: 1 → 2 → 3 → 1 → ... which will continue to jump as long as you keep clicking. The same can be said of Example #2 which will continue to jump between the game table and the character profiles as you click on links.

PART 2: OVERFLOW CONTROL
This is where the ~magic~ happens.

What It Is
Just like the real world, in the programming world "overflow" is excess information which does not fit within a predetermined space. The "overflow control" refers to how this excess information is handled. If you've used a scrollbar to scan through a page, you've experienced one form of overflow control -- scrolling.

Overflow control can be accomplished in HTML by using a style="" tag within a space tag (e.g. <div>, <p>, <table>, or <td>) which allows the use of CSS style properties to be used. In the case of overflow control, we are concerned with the dimension properties (e.g. width and height) and the overflow property.

For example, <div style="height: 100px; width: 50%; overflow: scroll;"></div> would create a space that is 100px tall and half the width of the page. Any text or code which overflows this space would cause a scrollbar to appear. The overflow text will become visible as you scroll.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sodales libero nec urna pellentesque rutrum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean rhoncus ullamcorper orci, at laoreet odio elementum sed. Integer nibh felis, fringilla ac vestibulum fermentum, rutrum in quam. Morbi lobortis feugiat tortor, non feugiat orci rutrum vel. Aenean rhoncus ullamcorper orci, at laoreet odio elementum sed. Integer nibh felis, fringilla ac vestibulum fermentum, rutrum in quam. Morbi lobortis feugiat tortor, non feugiat orci rutrum vel.


In a second example of the same space, the overflow property is set to visible. This setting will make all of the overflow text visible, but it lies outside of the predetermined space.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sodales libero nec urna pellentesque rutrum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean rhoncus ullamcorper orci, at laoreet odio elementum sed. Integer nibh felis, fringilla ac vestibulum fermentum, rutrum in quam. Morbi lobortis feugiat tortor, non feugiat orci rutrum vel. Aenean rhoncus ullamcorper orci, at laoreet odio elementum sed. Integer nibh felis, fringilla ac vestibulum fermentum, rutrum in quam. Morbi lobortis feugiat tortor, non feugiat orci rutrum vel.





Ugly, right? This is the default setting for the overflow property if you do not set it in your predetermined space.

Thirdly, the overflow property of the same space is set to hidden. This setting will hide any text or code that does not fit within the predetermined space.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam sodales libero nec urna pellentesque rutrum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean rhoncus ullamcorper orci, at laoreet odio elementum sed. Integer nibh felis, fringilla ac vestibulum fermentum, rutrum in quam. Morbi lobortis feugiat tortor, non feugiat orci rutrum vel. Aenean rhoncus ullamcorper orci, at laoreet odio elementum sed. Integer nibh felis, fringilla ac vestibulum fermentum, rutrum in quam. Morbi lobortis feugiat tortor, non feugiat orci rutrum vel.


Though the overflow text is hidden, we can still reach it through some simple page navigation!

How It's Used In This Code
All of your code will be going into a outer or main space that is roughly defined as:

<div style="height: 300px; overflow:hidden;">your code here</div>

The most important dimension in these codes is the height of your predetermined space -- the space where ALL of your other code is going to be contained. After you have sectioned off your code and information with page navigation, you need to determine the height of the tallest section.

In the case of the click-able icon, this is easy: 100px.

In the case of the game table with corresponding character profiles, the heights aren't as definite and there is always the possibility that someone will be viewing your page with different font defaults. Therefore, you need to create a buffer by adding extra height (around 100-200px is good) to your predetermined space to ensure everything is visible in your tallest section. You need additional buffers to ensure only one section appears in your predetermined space at any given time, which is accomplished by adding an ample margin to the bottom of each section. I use a bottom margin that is anywhere from half to 100% of the predetermined space height. This can be accomplished by adding a style tag style="margin-bottom: 300px;" to your section container or by adding a <div style="height: 300px;">&nbsp;</div> directly beneath the section.

Now, when click on your section links, your section should ~magically~ be appearing in your predetermined space.

That's it! [insert Kermit!YAY]

END CODE

RULES
    • Credit to [info]rp_tutorials. This is a must for the layouts, but not for the short codes.
    • Modify the short codes all you like. Check out the [info]rp_tutorial page for each layout for their rules.
    • Comments are appreciated.

THE CODE - SHORT VERSION


HOW TO USE
This is simply a 300px tall gray block that jumps to a 300pc white block and vice-versa. There is also a 300px margin between the two sections to ensure seamless jumping so it appears the gray sections turns to white and vice-versa.

Feel free to play with this code as much as you like.

THE CODE - EXAMPLE #2


HOW TO USE
This is the exact code for ONE of the game tables and corresponding character profiles from Example #2. You may fill in and expand these tables as you would for any layout. However, be aware of your height measurements! If the height of the game table or character profile is too large for all of it to be shown at once, you will need to increase the height of the <div> tag that controls the overflow. You may also need to increase the margins between each section so only one section is showing after any give jump.

Remember to give proper credit for any layouts you use!

Questions? Comments? Concerns?
Feel free to leave a comment to this entry or contact me at xvanyaeldax[at]gmail[dot]com.


(Post a new comment)


[info]hammertech
2009-05-05 08:14 am UTC (link)
This remains the coolest trick I have ever seen. Just sayin'. Thanks for explaining it!

(Reply to this) (Thread)


[info]wastintime
2009-05-07 12:14 am UTC (link)
Isn't it awesome?! My jaw hit the floor last night when I stumbled into that cast list.

And you're welcome. I'm hoping the explanation will minimize user confusion.

(Reply to this) (Parent)


[info]wastintime
2009-05-07 12:26 am UTC (link)
P.S. I have no idea which tags should be on this post.

(Reply to this) (Parent)


[info]scandalousmods
2009-05-06 03:24 am UTC (link)
It's awesome how I inspired you. :)

Yeah, it's really an awesome trick to use, especially when you have a long cast page. Scrolling is just a pain in the ass. My cast list, or the one you provide, is simple, yet efficient.. AND.. I get to supply even MORE information, than a conventional cast table. It's great.

Divs are man's gift from god.

btw; we're actually [info]scandalousmods ;-]

(Reply to this) (Thread)


[info]scandalousmods
2009-05-06 04:47 pm UTC (link)
Let me set something straight real quick.

The code that *I* received was created by my lovely, wonderful, awesome friend [info]define.

She graciously let me have the code. So, no inspiration, or anything would come from her not letting me use it.

ilu mise! <33

(Reply to this) (Parent) (Thread)


[info]wastintime
2009-05-07 12:24 am UTC (link)
Fixed and added!

It's great! I know of a couple people who are incorporating it into their CDJ character rosters. The click-able icon was an idea that came up while I was CAPSLOCKING with someone on AIM about the awesomeness of this HTML magic. (In the past, we've lamented the fact that journal sites don't allow mouse rollovers in entries.) Another fellow roleplayer had the bright idea that this could be used to simulate page turning for in-game newspapers, maps, etc. Yet another suggested it could be used to create additional fake lj-cuts behind real ones.

The possibilities seem to be endless. :]

(Reply to this) (Parent) (Thread)


[info]scandalousmods
2009-05-07 03:11 am UTC (link)
Awesome!

Thanks again! And I'll get that stuff done for you after class tomorrow, m'dear. :)

(Reply to this) (Parent)


[info]bad_username
2009-05-11 11:38 am UTC (link)
I'm going to try to figure this out and hopefully use it once I've figured it out.

(Reply to this)


[info]ohmygods
2009-05-13 12:03 pm UTC (link)
Figured it out!

It's still in progress, but I figured to share the temporary link.

(Reply to this) (Thread)


[info]scandalousmods
2009-05-14 02:31 am UTC (link)
Ello!

Pardon me, but it doesn't work for me. ;x It could be because I'm using IE; and it might work for me at school, but I'll just tell you what happens for me? =]

a) The DIVs get cut off. I'd suggest expanding them a good 100px or maybe even 50px.

b) I don't see a graphical switch between icons, if this was your intent? Instead, It just links me. You could probably do what Vanya did, and link the third icon, though? :)

(Reply to this) (Parent) (Thread)


[info]ohmygods
2009-05-14 08:38 am UTC (link)
a) The DIVs, I'm still working on them. Apparently I messed up last night and had to use a back up, hence DIVs being cut off. Could you possibly screencap what is going on? Is it the demigods table? I can see something is cut off there. (I've left out the address part on purpose, though.)

b) Oh, the three icon cycle, like in the Jerémie Renier example? I didn't incorporate that,figuring just to focus on the more difficult part of the coding for now. I do hope that's what you mean.

(Reply to this) (Parent) (Thread)


[info]scandalousmods
2009-05-14 08:14 pm UTC (link)
It looks good now! :) It was getting cut off, the second row was, midway.

And oh, Okay :D

Looks really nice :D

(Reply to this) (Parent) (Thread)


[info]the_tempter
2009-05-14 08:17 pm UTC (link)
Thank you! :D

And Emma Frost! &hearts

(Reply to this) (Parent)


[info]wokandroll
2009-05-24 05:55 am UTC (link)
okay, dumbest question ever?

i am using Example #2, and adding in a second game, but now, when i click on a character from game #1...the game #2 characters are right underneath. how do i make game #2 get outta there? i keep guessing at how to fix this, and RUINING EVERYTHING. i thought i would turn to the expert.

sigh: i le suck.

(Reply to this) (Thread)


[info]wokandroll
2009-05-24 05:58 am UTC (link)
here it is, so you can see my problemo in person, in case i explained it like a moron: http://wokandroll.insanejournal.com/25950.html

(Reply to this) (Parent)


[info]wastintime
2009-06-03 03:47 pm UTC (link)
I am so sorry I didn't get to this sooner. I haven't been on the internets much lately because I've been job desperate which takes up all my time. Anyway, it looks like you figured it out? I think? If you still have questions, just let me know.

(Reply to this) (Parent) (Thread)


[info]wokandroll
2009-06-03 03:49 pm UTC (link)
no worries! and i totally deleted it, because i couldn't get it to work and it drove me ca-razy. i'll try it again tonight and comment if I need some help again :)

GOOD LUCK WITH THE JOB STUFF <3

(Reply to this) (Parent)


[info]spreadsheets
2009-06-03 12:52 pm UTC (link)
This is fantastic and mindboggling and as someone who quit web design when CSS came into the picture, I bow down to you for making it so straightforward.

However, I have a question. What if I wanted to set up a link area, say, to the left of my content and have those links change the content in the designated area to the right? Is that possible? Is the only way to do it to recreate the links on the left in every individual [div] tag?

(Reply to this) (Thread)


[info]spreadsheets
2009-06-03 01:24 pm UTC (link)
You know what? Ignore me, I'm basically trying to make it act like frames, which is ridiculous, and not the point. If only iframes were compatible with IJ! SORRY!

(Reply to this) (Parent) (Thread)


[info]wastintime
2009-06-03 03:45 pm UTC (link)
Ah, don't be sorry. I actually realized what you want it to do and I just made a mini-version of it to check and yes, it does work. It involves a table and putting your links in one column and your div stuff in another column. I'll explain further when I'm not at work. ;]

(Reply to this) (Parent) (Thread)


[info]spreadsheets
2009-06-03 06:39 pm UTC (link)
You know, I did try that and had no luck, so I clearly don't know what I'm doing and look forward to hearing what you figured out!

(Reply to this) (Parent)


[info]drivencrazy
2009-06-08 04:44 pm UTC (link)
:) Best code EVER. I hate that it's spaced out in my page because it makes things look disjointed. But for what it's worth, it saves so much space. I'm so impressed with this code. Thank you SO much.

See it here but it'll be moved to [info]midnightmod shortly. Thank you again!!

(Reply to this)


[info]petitleprince
2009-07-04 09:54 am UTC (link)
Using this on this journal - over here. Credited in the OOC section! :D Thanks SO much for this, its such a spiffy effect!

(Reply to this)


[info]mods_smpaleo
2010-01-15 08:37 am UTC (link)
Used code with a location directory layout for results of AWESOME. See the results here. Thank you!

(Reply to this)


[info]turnskins
2010-09-02 07:27 am UTC (link)
I am using this code for my game's character directory here. I'm really pleased with the possibilities of hidden tables. Thank you so much!

(Reply to this)


[info]secret_mysterie
2011-03-15 07:05 am UTC (link)
I would love to add this capability to http://www.graiae.com/new/locations.php
the code found there, but have no clue how to accomplish it.

Would you be able to assist? I would adore you forever and ever!

(Reply to this) (Thread)


[info]secret_mysterie
2011-03-15 07:06 am UTC (link)
I guess it would be good to know that this will be going onto IJ. It is just easier for me to play with the code on my site and then just bring it over, especially when you can never tell when IJ will decide to misbehave.

(Reply to this) (Parent)


[info]evaakeru
2011-03-20 06:22 pm UTC (link)
I am hoping you're still active cause I could really use some assistance on this.

(Reply to this)



Home | Site Map | Manage Account | TOS | Privacy | Support | FAQs