Solved

enlarge div on mouseover

Posted on 2006-06-21
5
2,183 Views
Last Modified: 2010-05-18
I have a <div> element with an image inside of it.  The div is set for 50% width and 10% height.  The image also currently shrinks or expands as you resize the window.  What I want it to do.  Is increase to 70% width and 25% height when you move the mouse over the <div> then shrink back onmouseout.  Any ideas?

0
Comment
Question by:johnywhite
  • 2
  • 2
5 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 250 total points
ID: 16952964
Hi johnywhite,

Do you mean:

<div style="width:50%; height: 10%; border: 1px solid black;" onmouseover="this.style.width='70%'; this.style.height='25%';" onmouseout="this.style.width='50%'; this.style.height='10%';">Testing</div>

Regards,
Ted
0
 

Author Comment

by:johnywhite
ID: 16956440
Is there anyway to make it overlap other elements without setting the position absolutely?
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 16956458
Not that I know of. z-index works with both position absolute and position relative, but relative positioning keeps the object inline with the document so it will always create more space for it as it expands.
0
 
LVL 2

Assisted Solution

by:mazzachre
mazzachre earned 250 total points
ID: 16982967
Eventually you could:

function show_bigger() {
  document.bigger.style.top = mouse.y;
  document.bigger.style.left = mouse.x;
  document.bigger.style.display = block;
}

<div id="bigger" style="display:none; width:70%; height:25%; z-index:10;">

<div style="width: 50%; height: 25%;" onmouseover="show_bigger()">

Or place them at the same place and don´t move "bigger" with the mouse
0
 

Author Comment

by:johnywhite
ID: 17025394
They will work well enough for what I need thanks.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

832 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