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 51

Accepted Solution

Julian Hansen earned 500 total points
Comment Utility
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 51

Expert Comment

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

744 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

10 Experts available now in Live!

Get 1:1 Help Now