Advertisement

05.29.2008 at 01:57PM PDT, ID: 23442940
[x]
Attachment Details

In IE7, Can Div Scroll Vertically But Be Fixed Horizontally?

Asked by macrolific in Dynamic HTML (DHTML), JavaScript, Cascading Style Sheets (CSS)

Tags: DHTML, JavaScript, CSS

I have a page with dynamic content that often causes the page to grow taller and wider than the height and width of the browser window.  When this happens, vertical and horizontal scroll bars appear.

I also have an 800 pixel wide div on this page, top and center.  I would like for the div to always remain horizontally centered, regardless of horizontal scrolling, but to move up and down with the rest of the page when scrolling vertically.

I asked this exact question here a few hours ago, and a very bright and thoughtful person gave me what I thought was the answer.  Unfortunately, it turned out that this solution works in Firefox and Safari but not in IE7.  I'm posting the JavaScript I'm referring to below in case anyone knows of a way to modify it so that it would work in IE.  This script works when the div id is "test001" and has the following CSS style attributes:  "width: 800px; margin: auto;"

Thanks.Start Free Trial
1:
2:
3:
4:
5:
6:
<script>
  function move()
  {
    document.getElementById("test001").style.marginLeft = window.scrollX + 'px';
  }
</script>
[+][-]05.29.2008 at 02:10PM PDT, ID: 21673298

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Dynamic HTML (DHTML), JavaScript, Cascading Style Sheets (CSS)
Tags: DHTML, JavaScript, CSS
Sign Up Now!
Solution Provided By: ysfx
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.29.2008 at 02:14PM PDT, ID: 21673335

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 02:30PM PDT, ID: 21673452

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 02:46PM PDT, ID: 21673577

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 06:52PM PDT, ID: 21674721

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.30.2008 at 08:25AM PDT, ID: 21678646

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.30.2008 at 08:33AM PDT, ID: 21678731

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628