I have a header which has a large image floated on one side, and a small paragraph of text on the other side. I want the paragraph to start at the bottom of the header div.
http://jsfiddle.net/danheberden/ymwPe/
<div id="container">
<div id="gonnaBeOnTheBottom">
<p>Hi there!</p>
<p>I'm on the bottom!</p>
</div>
</div>
css:
#container {
background: #EEE;
height:400px;
width:400px;
position:relative;
}
#gonnaBeOnTheBottom {
position:absolute;
bottom:0;
}
by setting position:relative
on the parent container, you can absolute position elements inside of it :)
I recently came across a vertically center trick that I was able to adjust to server this purpose: http://codepen.io/Bushwazi/pen/VYBBmL
parent {
height: 200px;
}
child {
position: relative;
top: 100%;
transform: translateY(-100%);
display block
}
** Need to point out that browser needs to support CSS3 transform
: http://caniuse.com/#search=transforms
I made some changes in your code. Try this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style>
div#header {
height:200px;
}
div#header img#logo {
float:left;
}
.header p {
float:left
}
</style>
</head>
<body>
<div id='header'>
<img id='logo' src="../Pictures/myfarm.PNG" width="220" height="130" />
<p > ygkgi65iruyrftyhgffhfjgfhgjkhjfjhfjhfyj </p>
<p > ygkgi65iruyrftyhgffhfjgfhgjkhjfjhfjhfyj </p>
<p > ygkgi65iruyrftyhgffhfjgfhgjkhjfjhfjhfyj </p>
<p > ygkgi65iruyrftyhgffhfjgfhgjkhjfjhfjhfyj </p>
<p > ygkgi65iruyrftyhgffhfjgfhgjkhjfjhfjhfyj </p>
</div>
</body>
</html>
A more modern approach would be the usage of flexbox, that vastly eases the responsive work afterwards.
As flexbox free space distribution is managed with auto margins, you simply have to do the following :
margin-top: auto;
to the element that you want to stick at the bottom, flex will apply all the free space above#container {
background: #eaeaea;
height:180px;
display: flex;
flex-direction: column;
}
#bottom {
border: 1px solid blue;
margin-top: auto;
}
<div id="container">
<p>Container content</p>
<div id="bottom">
This flex content will stay at the bottom!
</div>
</div>