vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Sprite addition help (https://vborg.vbsupport.ru/showthread.php?t=297778)

Simon Lloyd 05-02-2013 10:45 PM

Sprite addition help
 
Hi all, i'm trying to replace all my forum images with a sprite reference, most of my images are on forumhome, could someone help with how i'd present the css instead of this
HTML Code:

<td><img src="$stylevar[imgdir_statusicon]/$forum[imageprefix]forum_$forum[statusicon].gif" alt="" border="0" height="46px" width="46px" id="forum_statusicon_$forum[forumid]" />
</td>

here's a snippet of my sprite css
Quote:

.Accessforum_new{ background-position: 0 0; width: 47px; height: 47px; }
.Accessforum_old{ background-position: 0 -97px; width: 47px; height: 47px; }
.Excelforum_new{ background-position: 0 -194px; width: 47px; height: 47px; }
.Excelforum_old{ background-position: 0 -291px; width: 47px; height: 47px; }
.Outlookforum_new{ background-position: 0 -388px; width: 47px; height: 47px; }
.Outlookforum_old{ background-position: 0 -485px; width: 47px; height: 47px; }
HTML Code:

#td {
    background: url(forumsprite.png) no-repeat top left;
}

So, not being any good whatsoever with css i'm assuming i'd reference the actual sprite like the code snippet above in my additional css? and how would i address the actual css references in the code snippet at the very top?

Any help is appreciated :)

EDIT: the image names in the css i.e Accessforum_old are the names of the prefixes as they are currently in use.

Lynne 05-03-2013 02:52 AM

You basically tell it where the upper left point is via x y position and then give the height and width from there.

http://www.w3schools.com/css/css_image_sprites.asp

Simon Lloyd 05-03-2013 02:55 AM

I've had limited success using <td id="td"> but it just shows the entire sprite, even if i then do <td id="td" class="$forum[imageprefix]forum_$forum[statusicon]"> i cant get it to show that particular part of the sprite, just using $forum[imageprefix]forum_$forum[statusicon] in the template shows the correct name for the sprite portion but no image?

--------------- Added [DATE]1367557259[/DATE] at [TIME]1367557259[/TIME] ---------------

i've made further modifications and have much better success although some of the images aren't showing correct and i think thats down to the generated image and css, i'll have a play now that i can actually see whats going on - thanks Lynne :)

darnoldy 05-03-2013 01:46 PM

Part of the problem may be that IDs have to be unique on a page. It appears that you're trying to have a <td id="td"> for each row in your forumhome table.

Put the {background: url(forumsprite.png) no-repeat top left;} into each of the class definitions and eliminate the #td selector altogether.

You might also try putting some content into the td— like a &nbsp; Table cells act weirdly when they are empty.

--don


All times are GMT. The time now is 07:12 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01132 seconds
  • Memory Usage 1,720KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_html_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete