Image Fit

Posted on 2013-01-30
Last Modified: 2013-01-31
Hi, I have the following table with an image on the background, The problem is that I havent been able to make it Fit without resizing the Div "Shrink"

<!doctype html>
  border:2px solid black;
  margin:30px 50px;
  border:1px solid black;
  filter:alpha(opacity=60); /* For IE8 and earlier */
div.transbox p
  margin:30px 40px;


<div class="background">
<div class="transbox">
<p>This is some text that is placed in the transparent box.
This is some text that is placed in the transparent box.
This is some text that is placed in the transparent box.
This is some text that is placed in the transparent box.
This is some text that is placed in the transparent box.


Open in new window

Question by:jhonc66
  • 2
LVL 54

Accepted Solution

Julian Hansen earned 500 total points
ID: 38838382
Your image is too large - you need to scale it to the size of your div. You can do this in CSS like so
line 5 of your html file change background-image to
  background:url("") no-repeat;
  background-size: 500px 250px;

Open in new window

Add the width and height to the background declaration

However, As Usual, this won't work in IE8 so alternatively resize your image or look here
LVL 54

Expert Comment

by:Julian Hansen
ID: 38842629
Thanks but as a matter of interest - why the B rating?

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
execute script based on HTML event 7 23
Width of Page is Affecting Side Menu 6 24
CSS: Making responsive table look nicer 7 23
Button and js nou working 3 6
This article discusses how to create an extensible mechanism for linked drop downs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now