Solved

CSS Background Image

Posted on 2013-02-01
7
283 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
Technology Partners: 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 500 total points
ID: 38847585
background : url("image.jpg") no-repeat center; or left top
Or
background-position: center; or left top
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to dynamically set the form action using jQuery.
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…

730 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