最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do i make a background image right click able? - Stack Overflow

programmeradmin1浏览0评论

I gave up on trying to center an image vertically and horizontally. I seen solutions that require you to know the size of the image. I do know background-image will center it properly. However i cannot right click the image and hit save as. Is there a trick i can use to allow this?

I gave up on trying to center an image vertically and horizontally. I seen solutions that require you to know the size of the image. I do know background-image will center it properly. However i cannot right click the image and hit save as. Is there a trick i can use to allow this?

Share asked Mar 19, 2010 at 14:50 user34537user34537 3
  • You may want to ask this question over at doctype. – Spoike Commented Mar 19, 2010 at 14:54
  • @Thomas: If you can give me an example and say use an image. I'll mark it as accepted – user34537 Commented Mar 19, 2010 at 15:07
  • @Thomas: stackoverflow./questions/2478434/… – user34537 Commented Mar 19, 2010 at 15:22
Add a ment  | 

6 Answers 6

Reset to default 4

You can always add an <img> in the <div> that you are setting the background for. And set the opacity to 0.

Users can't see it but they can still right click and save it.

No, this is not possible.
Background images are not intended to be any more than a pretty surrounding for the important parts and there is no reason why they should be easily downloadable.

Have you taken a look at this potential answer?

http://www.brunildo/test/img_center.html

His solution is pure HTML+CSS, doesn't require foreknowledge of the image height and works in: Opera 6+. Safari, IE5+/Win, and IE5/Mac.

In firefox you can view background images. Then you can save the image

Use Firebug plugin for Firefox. You can browse to the DOM element and then find the background image. Then there's an option to "open image in tab". From there saving it is simple.

I assume this is for development purposes and not something you want end users to do.

That depends on your browser -- in Firefox3, you may use Tools->Page Info->Media, locate the image from the list and hit "Save As..."

I think an HTML/CSS option is not possible, but I'm not pletely sure.

发布评论

评论列表(0)

  1. 暂无评论