Solved

Css place a image at bottom

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers 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 …

744 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

11 Experts available now in Live!

Get 1:1 Help Now