css-sprites

How do CSS sprites speed up a web site?

≯℡__Kan透↙ 提交于 2019-11-28 02:56:23
问题 I'm trying to understand how CSS sprites improve performance on a site? Why is the downloading of several small images slower than the download of a single image holding the smaller images if the total size of the single image is the sum of the smaller images? 回答1: It's important to understand why the overhead of an HTTP request has such an impact. In its simplest form, an HTTP request consists of opening a socket, sending the request on the open socket and reading the response. To open a

Clip/Crop background-image with CSS

别说谁变了你拦得住时间么 提交于 2019-11-27 19:57:15
I have this HTML: <div id="graphic">lorem ipsum</div> with this CSS: #graphic { background-image: url(image.jpg); width: 200px; height: 100px;} The background image I'm applying is 200x100 px, but I only want to display a cropped portion of the background image of 200x50 px. background-clip does not appear to be the right CSS property for this. What can I use instead? background-position should not be used, because I'm using the above CSS in a sprite context where the image part I want to show is smaller than the element on which the CSS is defined. Brent You can put the graphic in a pseudo

How do CSS sprites work?

瘦欲@ 提交于 2019-11-27 15:22:29
I have 3 different images and want to create a sprite using CSS. I understand that will reduce HTTP requests. However, I am totally new to this concept and have no idea as to how to approach this. What would be best bet for me? Also I have seen there are some CSS sprite generators where you submit a .zip of images and it combines them. I tried doing that, but did not understood what was happening. Any guidance regarding creating and using CSS sprites would be highly appreciated. Update: I have gone through the A List Part article but it was not very clear to me. Can someone provide an example

Best Way to Sprite Images?

[亡魂溺海] 提交于 2019-11-27 14:50:34
I am now getting to the point that I want to sprite the images on www.trailbehind.com. Most of the images are loaded by JavaScript functions, and I have lots of little images such as the map icons. Is there any software that supports this? I know that you can use Django-sprites if your images are in Django templates. And you can use GWT similarly, if you want to write some Java code. What's the best way to go about this for a website that is Python/Django with a Javascript front-end? I never show any HTML unless the user has JavaScript turned off. You can also use Glue . It's an open-source

Why use a sprite sheet rather than individual images?

时光怂恿深爱的人放手 提交于 2019-11-27 13:30:40
One thing I have noticed on some sites is that they use one BIIIIIIIG image containing lots of little images, then use CSS background-position to define the coordinates of each image, rather than use individual images. Here's where I'm at: Cons for using big sprite sheet Need to load a large image to just display even one small image Need to write (or generate) a long stylesheet with a class for each image Cluttering CSS with lots of class definitions may impact performance If one image changes (or another is added), cache problems may be encountered both on the image and the CSS associated

jQuery toggle to change image

回眸只為那壹抹淺笑 提交于 2019-11-27 13:12:10
问题 I have a list of divs with images in them: <div class="wizard-img"><%= image_tag("sources/pix/nyt.png") %></div> <div class="wizard-img"><%= image_tag("sources/pix/theguardian.png") %></div> When a user clicks the div, I'd like it to change the image to x-on.png, when clicked again, it'll change to x-off.png, and when clicked a third time it should revert to x.png. Is it possible to do this without manually specifying jQuery for every image change? Can I traverse the div and find the image

Customizing the output of Compass sprites

别来无恙 提交于 2019-11-27 07:11:48
问题 I have a top bar menu (that's based on Zurb's Foundation): This is the SCSS: .top-bar { .top-bar-section { ul { @import "menu-icons/*.png"; @include all-menu-icons-sprites; } } } Now, this does what expected, but the problem is that I want to style the a element inside each li elements (actually, I'd like to apply it to .top-bar.topbar-section.ul.li.a:before ). However, since the site is build in WordPress, and so the menu, I can only assign the class to the li element and I have no idea how

Using sprites with IMG tag?

早过忘川 提交于 2019-11-27 03:29:24
I understand how to use sprites, however, isn't a "src" attribute required for IMG tags? I could always use a SPAN or other tag and set the background/width/etc but it won't be semantically correct. Basically, I'd like to omit the SRC for an IMG tag and use just sprites, but am concerned about the HTML not being technically valid because of it. Thanks. About semantical correctness: When an image has semantical meaning, so it is considered to be content, use an IMG tag , without sprites, and a correctly set up ALT. When an image is just decoration, like the background of a box, background of a

What are the advantages of using CSS Sprites in web applications?

淺唱寂寞╮ 提交于 2019-11-27 03:14:42
问题 I'm working on a website with reasonably heavy traffic and I'm looking into using a CSS sprite to reduce the number of image loads in its design. Are there any advantages to using a CSS sprite besides reducing the amount of transmitted data? How much space do you really save? Is there a threshold where using sprites becomes worthwhile to a website? UPDATE: Thank you for your responses. They are obviously all very carefully thought out and present good sources to verify your points. I feel

Tools to make CSS sprites? [closed]

主宰稳场 提交于 2019-11-27 02:29:28
Are there any good tools to make css sprites? IDEALLY I'd want to give it a directory of images and an existing .css file that refers to those images and have it create a big image optimized with all the little images AND change my .css file to refer to those images. At the least I'd want it to take a directory of images and generate a big sprite and the .css necessary to use each as a background. Are there any good photoshop plugins or fully blown apps to do this? This will do 90% of the work for you: http://spritegen.website-performance.org/ . You'll still need to edit the rules yourself,