Any examples to know about css sprites? - css-sprites

I know about css sprites.. Now i want some examples of css sprites....
How did you manage to get css sprites work?

I usaully use the CSS background property. This property allows you to set a scroll argument of top and left as you can see in the example below. So the idea is to create one image with all states and simply position it based on the event like hover or other custom event in which you alter the elements CSS. I hope this helps.
.mySprite a
{
background: transparent url(/images/spriteButton.gif) no-repeat scroll 0 0
}
.mySprite a:hover
{
background: transparent url(/images/spriteButton.gif) no-repeat scroll 30 0
}

http://stylemeltdown.com/2007/10/22/image-sprite-navigation-with-css/
http://www.w3schools.com/css/css_positioning.asp
http://template.joomlart.com/ja_iris/index.php?option=com_content&view=section&layout=blog&id=4&Itemid=29

If you are using Firefox here is a simple way to get an idea of what a sprite is. Go to yahoo.com, right-click and View Page Info, click Media. Look for a file name having "sprite" in it.
This is one of the links:
http://d.yimg.com/a/i/ww/met/gsprite_071309.gif
You will see many background gradient images. You can use this file to play with. Now you have to adjust background position in your CSS depending on which background you want to use, like this:
background-image: url('http://d.yimg.com/a/i/ww/met/gsprite_071309.gif') left -30px repeat-x;
This should give you an idea of how to manage sprites.

If you are looking to create a CSS sprite - you can check out the site spriteme.org, which is very cool and shows you how to easily create a CSS sprite.
For a nice example you can check out this page:
http://www.programmerinterview.com/index.php/general-miscellaneous/css-sprite-example-and-tutorial/
Gives a good explanation and shows how the website owner uses a sprite.

I use them for button images. I use the top half of an image for the normal button state and the bottom half for the mouse-over state. That way the mouse over image is loaded when the page loads and there's no delay which just looks bad and slow. CSS code is here.

Check out this page:
http://www.tutorialrepublic.com/css-tutorial/css-sprites.php
It has a great interactive example and everything you need to know about CSS Sprite.

Related

Is there a known workaround for fixed elements rendering in the wrong place when the iOS virtual keyboard is on screen?

I've got an app which leverages a WKWebView for most of the content. In a few screens we have buttons in a div which leverages position: fixed; so that they're always in the same place as a long form scrolls underneath. When the virtual keyboard is shown I add a class to the document body that can be used to adjust other things, for example, tweaking the bottom property on the div containing these buttons so they move above the keyboard.
So far, so good, they're always visible. The problem arises when the form is then scrolled, the buttons visibly move up with the rest of the page (which they shouldn't), but the browser actually acts as if they're still position where they're supposed to be. The screen shot shows where the browser believes the buttons are, and if you touch those areas then the buttons get activated.
I'm happy to chalk this up as a bug with WebKit or specifically WKWebView, but is there a known workaround for this so that they render in the correct place? I read that adding a translation to trigger hardware rendering could help, but it doesn't seem to have done the job here. I also read that changing the position to absolute could solve this issue, but for me it just results in them being rendered off screen somewhere altogether.
You can add fixed position to button wrapper
.btn-bar-fixed {
position: fixed;
bottom: 0px;
right: 0px;
}

One Page parallax levels/layers

Not sure where to look for an answer, but here's my quest:
http://www.mobiliteitsvisie.nl/
On this site I've made a one page parallax, but when scrolling the main text moves underneath the menubar, but the headers (h3 & h4) seem to move over it...
But where would I need to adjust this? In the .css or in the .js file?
Thanks in advance!
Ruud
Since you're problem is with the style you need to make a change to the CSS.
In your case you want to get the menu on top of all other objects. Just give the menu container a large z-index.
Add this to your css file:
header {
z-index: 100;
}
The z-index property specifies the stack order of an element.
An element with greater stack order is always in front of an element with a lower stack order.
Note: z-index only works on positioned elements (position:absolute, position:relative, or position:fixed).
Additional question about the same site. When scrolling through the site, the menu-item should change with every slide it passes. At this moment the last clicked menu-item is highlighted, even when scrolling through to the several slides. Is there an easy way to make that work in CSS? Or would that be possible by just adding a jQuery.nav.js to the index.html?

How to make a CSS background image (sprite) to clickable area?

At the example of YouTube.
Their logo comes in fact from a big master image containing other graphical elements. However one can click on the logo which point to the root of the site. I'm researching their HTML but still not quite sure how they achieved that.
Could anyone please look at it and maybe explain it?
It's basically just a button inside link with a background image, but with it's width and height constrained to only show the portion of the background image / sprite with the YouTube logo.
From their CSS:
#masthead #logo button {
background-position:0 0;
height:33px;
width:84px;
}
If you load it up in Firebug and change the height you will see more / less of the background image appear.
From their HTML source:
<button onclick="window.top.location.href='/'; return false;" class="master-sprite" title=""></button>

How to change the color/size of one progress bar

I'm pretty new to jQuery-UI, but I love what I see so far.I am using the 'blitzer' theme (as I needed red progress bars) and I have 4 progress bars side-by-side on one page. Now my PM wants one of them to be green, and bigger than the rest. I looked around the provided theme CSS but couldn't find the right tag to tinker with. Can anyone post a short code of 2 progress bars with different sizes/colors side by side?
Bonus question: I was asked to print the PB's percentage in the PB itself - no biggie - I just added a label inside the div. The problem is the text in the label is colored white, so if the PB is empty or half-empty, the text becomes invisible. Is there any way to control the background color of the PB, or is it a given inside a theme?
Thanks a lot!
Guy
This is how the bars are set up, so modify the classes inside them.
<div class="ui-progressbar ui-widget ui-widget-content ui-corner-all">
<div style="width: 37%;" class="ui-progressbar-value ui-widget-header ui-corner-left"></div>
</div>
(Its at the bottom of the badge)
Modify ui-progressbar and ui-progressbar-value.
Traveling Tech Guy:
If you look in the css folder of your jQueryUI download, you will find a theme folder; mine is called ui-lightness, yours is probably called ui-blitzer. Go into that folder, and then into the images folder. There, you will find some image files that start with the letters ui-bg_diagonals and ui-bg_gloss. These are the images that drive the progress bars. You should be able to add some images from another theme that are the colors you want, which will drive your other status bars.
In addition, there is a css entry called .ui-widget-overlay that references the image ui-bg_diagonals-thick_20_666666_40x40.png, which I think is the image that actually drives the progress bar. You will have to hack the css so that you can add a new class that references your new image in the other progress bar; I haven't figured out how to do that yet.

sifr Problem - everything invisible

As far as I use sifr.setup(); every h2, h1, and so on becomes invisible. But I don't want that.
I just want the "selectors" to provide a replacement and become invisible and replaced.
How can I prevent that?
I also have another problem where every font is blue and it never gets that color from anywhere.
Sounds like you've kept the original CSS, which hides those elements. Have a look at the CSS file and remove the original .sIFR-hasFlash h1 selectors.
Can you post an example for the color problem?

Resources