Solved

Css place a image at bottom

Posted on 2009-04-07
4
1,505 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
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 …
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…

863 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

23 Experts available now in Live!

Get 1:1 Help Now