Solved

Image Fit

Posted on 2013-01-30
2
275 Views
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>
<html>
<head>
<style>
div.background
  {
  width:500px;
  height:250px;
  background-image:url("http://writing-jobs-uk.com/wp-content/uploads/2012/06/green-energy.jpg");
  border:2px solid black;
  }
div.transbox
  {
  width:400px;
  height:180px;
  margin:30px 50px;
  background-color:#ffffff;
  border:1px solid black;
  opacity:0.6;
  filter:alpha(opacity=60); /* For IE8 and earlier */
  }
div.transbox p
  {
  margin:30px 40px;
  font-weight:bold;
  color:#000000;
  }
</style>
</head>

<body>

<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.
</p>
</div>
</div>

</body>
</html>

Open in new window

0
Comment
Question by:jhonc66
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 58

Accepted Solution

by:
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("http://writing-jobs-uk.com/wp-content/uploads/2012/06/green-energy.jpg") 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
http://stackoverflow.com/questions/4885145/ie-8-background-size-fix
0
 
LVL 58

Expert Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
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…

635 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