Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lame question I know...

Status
Not open for further replies.

wagnj1

Programmer
Jul 21, 2003
154
CA
ok so I haven't used CSS for awhile and I can't remember something...
I have a picture that I want to place over a background in my html. the background is an empty polaroid and the main image should be displayed only in the white area of the polaroid, meaning that its offset at the top left corner by a bit. what would be a good style for this?
 
thanks for the tips. the image is still not going any further to the top of the polaroid though. it seemed to go to the top fine before I added the style class for the background polaroid image. might that have something to do with it?
 
does anyone know if using the background property in a style sheet affects data inside of it if its used on table date?
 
wagnj1 said:
does anyone know if using the background property in a style sheet affects data inside of it if its used on table date?
It does not. You've been bombarded with many different solutions here and most of them should work, though not all of them bundled up. Let's review. First, define your workspace:

1. Add height and width to your td (I suggest using CSS)
Code:
<style type="text/css">
.polaroid {
  width: 200px;
  height: 300px;
} 
</style>
...
<td class="polaroid"></td>
2. Add background to your td (make sure your background is as big as the cell size):
Code:
<style type="text/css">
.polaroid {
  width: 200px;
  height: 300px;
  background: url(polaroid.gif) top left no-repeat;
} 
</style>
3. Add gutter so that content in the td will be positioned correctly (this gutter can be achieved by putting margins to the img that we will use or padding to the td)
Code:
<style type="text/css">
.polaroid {
  width: 200px;
  height: 300px;
  background: url(polaroid.gif) top left no-repeat;
  padding-top: 20px; /* or whatever you need */
  padding-left: 15px; /* or whatever you need */
} 
</style>
4. Style your image. This is for easier maintainability and better cross-browser support:
Code:
<style type="text/css">
.polaroid img {
  display: block;
  width: 170px;
  height: 240px;
} 
</style>
You should be set. Having td with class polaroid and img inside that your code should work as expected.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top