Solved

Css place a image at bottom

Posted on 2009-04-07
4
1,508 Views
Last Modified: 2012-08-14
Hi,

I hope someone can help me. I have a div that use a class for the font:
font-size: 12px;
font-weight: bold;
color: #333333;
margin-left: 8px;
text-align: left;

Now I want to place a image inside this div, in front of the text.
<div><img>Text</div>
How I can make it working that the image is allways at the bottom of the div? I tried a few ways but it is allways not at the bottom and IE and FIrefox will place it everytime different.

I hope someone can help me.

Ocrana
0
Comment
Question by:Ocrana
[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
4 Comments
 
LVL 30

Expert Comment

by:LZ1
ID: 24088553
Can you post the rest of your code or a live link?
0
 
LVL 11

Accepted Solution

by:
level9wizard earned 500 total points
ID: 24088610
<!-- THE HTML -->

<div id="myDiv">
    <img src="image.jpg" id="myImage" alt="" />
</div>


/* THE CSS */

#myDiv
{
    border: 2px solid black;
    background: #cecece;
    position: relative;
    height: 200px;
    width: 200px;
}
#myImage
{
    position: absolute;
    bottom: 0; left: 0;
}
0
 
LVL 11

Expert Comment

by:level9wizard
ID: 24088664
My first comment shows simply how to force an image to the bottom of its containing div. The below code also shows how to put text inside the image as it's div is really a background image:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Test</title>
<style type="text/css">
	#myDiv
	{
		border: 2px solid black;
		background: #cecece;
		position: relative;
		height: 200px;
		width: 200px;
	}
	#myImageContainer
	{
		position: absolute;
		bottom: 0; left: 0;
		background: Red url('image.jpg') no-repeat;
		height: 100px;
		width: 100px;
	}	
</style>
</head>
<body>
	<div id="myDiv">
		<div id="myImageContainer">hello world</div>
	</div>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:Ocrana
ID: 31567570
This helped us very much!
0

Featured Post

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!

Question has a verified solution.

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

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…
This article discusses four methods for overlaying images in a container on a web page
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
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…

726 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