/    Sign up×
Community /Pin to ProfileBookmark

Align images to bottom of container.

In the following script, I have used a table to make the images align to the bottom of the table border where the image grow UP when moused over.

How do I accomplish the same thing with CSS in the ‘Container’?
I want the images to be initially lined up along the bottom and then ‘grow’ when moused over.

I cannot figure how to set the bottom of the image to the bottom of the “Container”. ?

[code]
<html>
<head>
<title>Roll-over image enlarger</title>

<style type=”text/css”>
#Container { height:200px; width:400px; border:1px solid blue; }
#pic1, #pic2, #Cpic1, #Cpic2 { height:125px; width:100px; bottom-margin:0px; }

</style>

<script type=’text/javascript’>
// From: http://www.dreamincode.net/forums/showtopic136650.htm

var oheight = 125;
var owidth = 100;
var nheight = Math.floor(oheight*3/2); // scaling factor of 1.5
var nwidth = Math.floor(owidth*3/2);

function popImg(open,pic) {
if (open) {
document.getElementById(pic).style.height = nheight+’px’;
document.getElementById(pic).style.width = nwidth+’px’;
} else {
document.getElementById(pic).style.height = oheight+’px’;
document.getElementById(pic).style.width = owidth+’px’;
}
}

</script>
</head>
<body>
<!– One method that works –>
<table border=”1″><tr><td valign=”bottom” height=”200″ width=”400″>
<img src=”http://www.nova.edu/~rumsey/snoopy.gif” id=”pic1″
onmouseover=”popImg(true,this.id);” onmouseout=”popImg(false,this.id);”>
<img src=”http://www.nova.edu/~rumsey/BanjBird.GIF” id=”pic2″
onmouseover=”popImg(true,this.id);” onmouseout=”popImg(false,this.id);”>
</td></tr></table>
<!– –>

<div id=”Container”>
<img src=”http://www.nova.edu/~rumsey/snoopy.gif” id=”Cpic1″
onmouseover=”popImg(true,this.id);” onmouseout=”popImg(false,this.id);”>
<img src=”http://www.nova.edu/~rumsey/BanjBird.GIF” id=”Cpic2″
onmouseover=”popImg(true,this.id);” onmouseout=”popImg(false,this.id);”>
</div>

</body>
</html>
[/code]

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@justinbarneskinNov 07.2009 — [code=html]<div id="Container" style="position:relative">
<img src="http://www.nova.edu/~rumsey/snoopy.gif" id="Cpic1" style="position:absolute;bottom:0px"
onmouseover="popImg(true,this.id);" onmouseout="popImg(false,this.id);" >
<img src="http://www.nova.edu/~rumsey/BanjBird.GIF" id="Cpic2" style="position:absolute;bottom:0px;left:100px"
onmouseover="popImg(true,this.id);" onmouseout="popImg(false,this.id);">
</div>
[/code]
Copy linkTweet thisAlerts:
@justinbarneskinNov 07.2009 — The container must have style absolute or relative for the nodes to have their positioning to be effective within. Leave out container's style to see
×

Success!

Help @JMRKER spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...