So what i want to do is, when a button is rolled over i want to expand the outer div the button is sitting in not its own div, but the div on the outside of the button wich is a <nav></nav> div.
So the structure would look like this in html
<nav>
<a href="#" class="#"><img src="Menu.jpg /></a>
</nav>
I have rules governing the img within the <a></a> anchors what i want it to do is with the img is rolled over it changes the height of the nav div.
Please help?
OK, here we go, this should be simple enough...
We're going to use a style swapper. Put this in your <head> section...
<script type="text/javascript">
function enlarge(id)
{document.getElementById(id).style.height = '100px';}
function shrink(id)
{document.getElementById(id).style.height = '80px';}
function toggle(id)
{if(document.getElementById(id).style.height == "80px")
{document.getElementById(id).style.height = "100px";}
else{document.getElementById(id).style.height = "80px";}}
</script>
Now what this will do is swap out a height with a new height in your CSS. You can use whatever heights you want, just make sure the large one is right after the enlarge function and the small one is after the shrink function, then it needs to go "small large small" in the toggle function.
Here's an example of the CSS...
#div1, #div2, #div3 {
position:relative;
top:45px;
display:block;
width:577px;
border:1px solid black;
padding:10px;
border-radius: 0 0 10px 10px;
overflow:hidden;
height:80px;
}
#wrapper {
position:relative;
margin:auto;
width:610px;
}
That can go in the <head> or in an external sheet, all you really need to know is all of your div tags need to start at the "shrink" setting from the javasscript. You can name your divs anything you like. Just make sure you use id's for your divs (#) and not classes (.), that won't work with the javascript.
Here's an example of the HTML. This would go in your <body>...
<div id="wrapper">
<p><a onmouseenter="enlarge('div1'); shrink('div2'); shrink('div3');" onmouseout="shrink('div1');">Services</a></p>
<p><a onmouseenter="shrink('div1'); enlarge('div2'); shrink('div3');" onmouseout="shrink('div2');">Products</a></p>
<p><a onmouseenter="shrink('div1'); shrink('div2'); enlarge('div3');" onmouseout="shrink('div3');">Contact Us</a></p>
<div id="div1">
<p>div1 div1 div1 div1 div1 div1
div1 div1 div1 div1 div1 div1
div1 div1 div1 div1 div1 div1
div1 div1 div1 div1 div1 div1
div1 div1 div1 div1 div1 div1
div1 div1 div1 div1 div1 div1 </p>
<p>div1 div1 div1 div1 div1 div1
div1 div1 div1 div1 div1 div1
div1 div1 div1 div1 div1 div1
div1 div1 div1 div1 div1 div1 </p>
</div>
<div id="div2">
<p>div2 div2 div2 div2 div2 div2
div2 div2 div2 div2 div2 div2
div2 div2 div2 div2 div2 div2
div2 div2 div2 div2 div2 div2
div2 div2 div2 div2 div2 div2
div2 div2 div2 div2 div2 div2 </p>
<p>div2 div2 div2 div2 div2 div2
div2 div2 div2 div2 div2 div2
div2 div2 div2 div2 div2 div2
div2 div2 div2 div2 div2
div2 div2 div2 div2 div2 div2 </p>
<p>div2 div2 div2 div2 div2 div2
div2 div2 div2 div2 div2 div2
div2 div2 div2 div2 div2 div2
div2 div2 div2 div2 div2
div2 div2 div2 div2 div2 div2 </p>
</div>
<div id="div3">
<p>div3 div3 div3 div3 div3 div3
div3 div3 div3 div3 div3 div3
div3 div3 div3 div3 div3 div3
div3 div3 div3 div3 div3 div3
div3 div3 div3 div3 div3 div3
div3 div3 div3 div3 div3 div3 </p>
<p>div3 div3 div3 div3 div3 div3
div3 div3 div3 div3 div3 div3
div3 div3 div3 div3 div3 div3
div3 div3 div3 div3 div3 div3
div3 div3 div3 div3 div3 div3 </p>
</div>
</div>
Right now, all the divs are set to their small setting by the CSS. When you mouse over them, they grow to their large setting because of the onmouseenter="shrink('div1'); shrink('div2'); enlarge('div3');" onmouseout="shrink('div3'); added to the links (Services Proiducts and Contact Us). That onmouseenter can also be added to an <img /> tag and will do the same thing. The important thing to see is that on mouse enter it will enlarge one div and shrink all of the others, this way you don't enlarge a div by moving the mouse onto an image or link and just leave it expanded when you mouse out to another.
That aught to do it, let me know if you have any questions.
Neither. Don't worry about the "getElementById(id)" in the javascript, you don't need to name your divs after anything in the javascript itself.
You can name your divs anything you like, you would just replace ('div1') with ('yourdivname') in the onmouseenter attribute of your link or image that controls the enlarge/shrink action.
one more thing could u possibly help me with?
when the button is scrolled over, i want to swap out an image in another div that is within the same large div as before the image in question is an arrow that will go from pointing downward to pointing left. I have the 2 images i need to i just need to swap them.
thank you again!
LOL, wut?
I think what you want is called a disjointed (I like calling them remote) rollover.
You can make a remote rollover within DW pretty easily.
First, make sure you know the id's and the file names of the images you plan to use.
Then in Design View click the image you want to add a mouse rollover action on (image1).
Click the + in the Behaviors tab and choose Swap Image.
In the menu that pops up, choose the image you want to have the actual change on (image2) from the list.
Click Browse after the Set source to: and choose the file name you want image2 to change to.
Leave both the preload and restore image checked.
Click OK.
The end.
yeah that sounds like it will work. thanks.
I am sorry to keep bothering you like this but, i set the buttons div to expand when i roll over it in CSS by using height:300px; wich makes it so it does not expand once the button is rolled off of I have link that are hidden in the larger div. I am making a drop down menu, but I have to make it a particular way. Well anyways once the div expands to 300px on hover it must be pushing the other links that are hidden even further dowward because they are not there.
my question is how do i make the links below wich are named .breakfast , .lunch, and .drinks ignor the div above them so the expanding div size does not push them downward changing their position? or is there a better way of doing the same thing?
http://creationsmh.com/Pages/about.html that is my website the other pages are not up yet just what I have on the one page that is actually going to be the template that i am working on.Do not preview it Internet Explorer it does not work use something else.
When you hover over the menu link thats where the drop down occurs. Notice how there is nothing below it. That is because the links are being pushed downward i have the overflow set to hidden. What i want to do is make it so the Breakfast, Lunch , and Drink links are being see while still having that button stay as you scroll over top of them and not have content shrink when you roll off the button that is why i used #menu:hover{ height:220px; } if you look at the code in an element inspector you will see what i did in the CSS.
I made it that way so that when the user rolls over the menu button and moves the cursor down it wont shrink. what is going to be the best way to go about making it so that when the user rolls over menu and wants to the get the other 3 links below it does not shrink to its original state?
It works!! Thanks I couldnt have done it without you! one more question i dont know if u'll know this one how widly accepted is CSS3 is it accepted by older browsers like the earlyer versions of Firfox IE 7 and 8, and early versions of Chrom and Opera? and can i reformat my CSS2 into CSS3? what i want to do it change the opacity of the links and i dont think i can do that in CSS2.
CSS3 is not standard in any browser. The newest browsers don't implement all of CSS3 yet, and even some of the attributes they do accept, need to be written out 3-4 different ways. The older the browser, the worse it gets, by far.
Opacity needs 2 versions, one for everything but IE and one for IE
img
{
opacity:0.4;
filter:alpha(opacity=40); /* For IE8 and earlier */
}
I "think" support goes back a ways as long as you use the filter:alpha
Here's an excellent reference page:
Sorry, with this particular code, no.
It's possible if we were using a class switcher, but right now it's just a style switcher that affects only the height attribute. It would require re-writing the javascript and most of your styles.
On a class switcher all you would do is add in transition css to the classes that it switches.
Huh thats strange because what i am looking at in FF 13 and IE 9 is completly different. i will take a screen shot and post it below. One more question how do i make a new command in the javascript and have two different messurments because i have another drop down menu at the bottom but the change in heights needs to be smaller.
http://i1114.photobucket.com/albums/k528/jeepsguy/screenshot.jpg
its completly messed up on the other borwsers it looks fine. I cant figure out how to make a new block of code to make it so i can have two different messurments.
North America
Europe, Middle East and Africa
Asia Pacific