Solved

Enlarging a Div

Posted on 2013-12-29
4
348 Views
Last Modified: 2013-12-29
When I click on a link I am trying to get a div to enlarge.  The div is called "sidebox".  The website is www.mediascrubber.com  The div is the white box with the grey line around it.

<ul id="bars">
		<li><a href="#!/page_One">One</a><!-- Begin One -->
    	<li id="page_One">
			<div id="sidebox" class="sidebig">
			</div>
		</li>
    	</li><!-- End One -->
	</ul>

Open in new window


I want it to work like www.legalzoom.com
0
Comment
Question by:DS928
  • 2
  • 2
4 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39745060
This is based no jquery - I'm sure you can easily adapt it to your particular code
http://jsfiddle.net/GaryC123/6adEM/1/

HTML
<div id="container">
    <div class="buttons">
    <button id="but1">button 1</button>
    <button id="but2">button 1</button>
    </div>
    <div class="content">
    <span class="but1">some text</span>
    <span class="but2">some other text</span>
    </div>
</div>

Open in new window

CSS
#container {
    height:100px;
    width:100px;
    overflow:hidden;
    border:1px solid green
}
.buttons {
    width:90px;display:inline:block;float:left
}
.content span{
    width:90px;
    display:inline-block;
    float:left;
    display:none
}

Open in new window

JQUERY
$("#container").mouseenter(function(){
        $(this).animate({width: '200px'});
})
$("#container").mouseleave(function(){
        $(this).animate({width: '100px'});
})
$(".buttons button").hover(function(){
  $(".content ."+$(this).attr("id")).toggle()  
})

Open in new window

0
 

Author Comment

by:DS928
ID: 39745119
Your example works great.  Mine doesn't.  I copied all of the code and it doesn't seem to work.  Could it be my jquery version?

<script type="text/javascript" src="js/jquery-1.7.2.min.js" ></script>
<script>
		$("#container").mouseenter(function(){
        $(this).animate({width: '200px'});
		})
		$("#container").mouseleave(function(){
        $(this).animate({width: '100px'});
		})
		$(".buttons button").hover(function(){
  		$(".content ."+$(this).attr("id")).toggle()  
		})
</script>

Open in new window

0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39745121
Wrap your script in

$(function() {
...
})

Open in new window

So it doesn't fire until the page has loaded and the elements exist, at the mo you have it before the html so they don't actually exist when the js is fired.
0
 

Author Closing Comment

by:DS928
ID: 39745138
Bingo!  That was it!  Thank you.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
push Book Today button to right 10 37
html input 8 43
<div class="clearfix"></div> not working on home slider 5 20
message Alert on an empty search 10 22
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

828 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