How to subtract background from an image?

In CSS, how do I place an image directly above or below a background image?

  • The body div of my website has a repeating background image.  I wish to create an effect of three-dimensionality by dropping a shadow from the bottom of the background image and adding a little structure to the top of the background image.  These “structure” images have already been created in Photoshop.  All I would like to do is place them directly above and below the body’s background image.  Can anyone suggest the proper CSS syntax to do this?

  • Answer:

    Thanks, Alexander.  I’m afraid I should have been more specific. I attribute the confusion to the fact that I didn’t really know what I was doing.  My html is generated by php files, but I’m using WordPress, so I didn’t build the php myself.  I wanted to insert an image above a “content” div.  I wondered, “Do I need to create a new div and position it above #content?  Do I need to create a new class within #content and play with the “position” tag?”  It turns out I needed to do something like this: <?php get_header(); ?> <div id="content" class="col-full"> <img src="image.jpg"/> <div id="main" class="col-left"> I introduced the image within the #content div and then played around with the CSS: #main{width:600px; margin-left: 25px; margin-top: 20px; margin-bottom: 20px; } to get it positioned correctly.

Mike Specian at Quora Visit the source

Was this solution helpful to you?

Other answers

Very carefully. But srsly: body { background-image: url(bg.jpg); } div#theeffectofthreedimensionality { background-image: url(structure.jpg); position: absolute; left: /* insert x offset from left here */; top: /*insert y offset from top here */; width: /* what it needs to be */; height: /* the same */; overflow: hidden; } something like that should do it.

Alexander Bohn

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.