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
Solved

Css place a image at bottom

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
push Book Today button to right 10 36
Hide cell in a table 2 27
Call a function within the ASP code 4 19
Diminish Pop-up  in 3 seconds 7 47
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

856 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