Solved

Css place a image at bottom

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
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…

821 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