So i have a rectangle, 100% width of the page, and a height of 115 or so. On hovering, the box expands to a height to 225. How, through CSS code, can i get 3 smaller divs to appear in the hover box of 225 height and 100% width? Thanks!
<html>
<head>
<title>Testing</title>
<style>
div {border: 1px inset red}
div#a, div#b, div#c {display: none; height: 100px; float: left}
div#container {height: 100px}
div#container:hover {height: 125px;}
div#container:hover div {display: inline}
</style>
</head>
<body>
<div id="container">
Content for div container
<div id="a">Content for div a</div>
<div id="b">Content for div b</div>
<div id="c">Content for div c</div>
</div>
</body>
</html>
http://jsfiddle.net/6wd7s/8/
first: no space between #two and :hover in your CSS declaration.
second: this "#two:hover div" targets all divs on the page when you hover over #two.
third: you want to display those a, b, c divs as inline-block, not just inline (they don't have any content and you want to control their height too).
Follow up question... how would i evenly split up the 3 div across the width of the page? Also, how would i center a header?
<html>
<head>
<title>Centered header and 3 div equal width in dynamic container</title>
<style>
body {margin: 0}
#header-container {
border: 1px inset red;
width: 100%;
}
#header-inner {
margin: 0px auto;
text-align: center;
font: bold 24px arial;
background-color: yellow;
}
.xouter3{
width:100%;
border:1px inset #000;
float:left;
}
.xleftcol3{
float: left;
width: 33%;
background:#809900;
}
.xmiddlecol3 {
overflow:hidden;
background:#eff2df;
}
* html .xmiddlecol3{float:left}
* html .xmiddlecol3 .xinner3{width:100%;}
.xrightcol3 {
float:right;
width: 33%;
background:#d2da9c;
position:relative;
}
</style>
</head>
<body>
<section id="header-container">
<div id="header-inner">This is a Header</div>
</section>
<div class="xouter3">
<div class="xleftcol3"><p>This is the left col </p></div>
<div class="xrightcol3"><p>This is the rightcol : </p></div>
<div class="xmiddlecol3">
<div class="xinner3"><p>This is the middlecol: </p></div>
</div>
</div>
</body>
</html>
<div id="mydiv" style="display:none;">
document.getElementById("mydiv").style.display = "block";
Another simple way to go about it is having the smaller divs with the:
Code:<div id="mydiv" style="display:none;">
and upon hover, just call a javascript function and do this to view the div:
Code:document.getElementById("mydiv").style.display = "block";
No offence, but this is bad advice. If you can do it solely with CSS, don't do it with Javascript.
And if you've got to do it with Javascript, don't do it with inline Javascript.