?
Solved

CSS Background Image

Posted on 2013-02-01
7
Medium Priority
?
285 Views
Last Modified: 2013-02-16
I have a div with a background image.  I am trying to maintain a responsive design.  However, the background image will not show without an actual height.  Any ideas or work arounds?

#in_depth {
	display:block;
	background-image:url(../img/products/icons/in-depth.jpg);
	background-repeat:no-repeat;
	min-width:50%; 
	min-height:50%;
	float:left;
	background-size:100%;
}

Open in new window

0
Comment
Question by:rgranlund
[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
7 Comments
 
LVL 8

Expert Comment

by:albacom
ID: 38844925
Try:

Height:100%; ie
Overflow:hidden; ff
0
 
LVL 7

Author Comment

by:rgranlund
ID: 38844973
that did not work
0
 
LVL 30

Expert Comment

by:LZ1
ID: 38845083
I'm not sure what your background image is or how it's being displayed, but you may want to include a responsive background as well:
http://www.onextrapixel.com/2012/03/02/using-css-background-size-responsively/
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:LZ1
ID: 38845112
Here is a much better resource:
http://www.css3.info/preview/background-size/
0
 
LVL 8

Expert Comment

by:albacom
ID: 38846936
Try to define the backround-position
0
 
LVL 6

Expert Comment

by:nickinthooz
ID: 38847184
#in_depth {
	display:block;
	background:url('../img/products/icons/in-depth.jpg') no-repeat;
	min-width:50%; 
	min-height:50%;
	float:left;
	overflow: hidden;
}

Open in new window


A div will not adjust to your background size.  If you have a background image that is 300 x 300 and you only have the letter "a" inside your div, your div will collapse to the size of the "a" unless you specify a height and width. We could help a lot more if we knew what your background image was and also what is inside the div.

To see what I'm saying, use this fiddle example, take the height and width out of the div and hit run, and you'll see what I'm talking about.

http://jsfiddle.net/eZhAH/1/
0
 
LVL 8

Accepted Solution

by:
albacom earned 2000 total points
ID: 38847585
background : url("image.jpg") no-repeat center; or left top
Or
background-position: center; or left top
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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 embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 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