[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Top Expression CSS to JS

Posted on 2011-05-03
16
Medium Priority
?
1,571 Views
Last Modified: 2016-10-06
I have an example that uses top:expression(this.offsetParent.scrollTop); in CSS that is associated with the element ID header to set a fixed scrollable header. The parent div is what actually scrolls.

I know that epxressions are bad in CSS and that they are not supported in IE8. I would like to move this to javasript.
Please do not suggest a restructure, I am using this layout for a reason (variable width, may or may not have a scrollbar, etc). I am strictly interested in moving the top expression from CSS to JS. Thanks in advance.

<div id="parent" onScroll="scroll()">
  <table>
    <thead>
      <tr id="header">
        <th></th>
      </tr>
    </thead>
    <tbody>
      <tr>
       <td></td>
      </tr>
    </tbody>
  </table>
</div>

Open in new window

0
Comment
Question by:MelMc
  • 6
  • 4
  • 3
  • +2
15 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 35585941
Where is the css and function scroll ?
Did you try conditional comments and position:fixed?
0
 
LVL 8

Author Comment

by:MelMc
ID: 35690176
I wasn't going to put up all the CSS and the JS function is what I need help with...the question is just about converting the CSS function I mentioned to JS
0
 
LVL 9

Expert Comment

by:BobHavertyComh
ID: 35690736
CSS has no functions. scroll() is already a javascript function and you are using an html event to call the javscript function called scroll. Somewhere, you have to have a javascript function called "scroll" to prevent the page from crashing.

What do you want the page to do??
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:BobHavertyComh
ID: 35690743
can you also just give the url of your page if it is out on the web? Or, could you copy and paste all of your source code here?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 35691604
0
 
LVL 8

Author Comment

by:MelMc
ID: 35691907
It's not on the web. See attached.
I am looking for help writing the scroll function to eliminate the CSS expression...
#NGPTicketsLoadingImage
{
    text-align:center;
    height:100px;
    padding:50px 0 0 0;
}
.MyOpenTicketsError,
#NGPMyOpenTicketsNoTickets
{
    padding:8px 8px 0 8px;
    overflow:auto;
    overflow-x:hidden;
    margin:0 0 5px 0;
    height:auto;
}    
#NGPTicketsPanelUpdate
{
    height:145px;
    max-height:145px;
    position:relative;
    overflow:auto;
    overflow-x:hidden;
    min-width:182px;
    margin:0 0 5px 0;
}    
.NGPMyOpenTicketsTable 
{
    width:100%;
    border-collapse:collapse;
    margin-bottom:5px;
    height:auto;
    table-layout:fixed;
}
.NGPMyOpenTicketsTable a:hover
{
    text-decoration:hover;
}    
.NGPMyOpenTicketsTable>thead
{
    background-color:#F2F2F2;
    padding:0;
    margin:0;
}    
.NGPMyOpenTicketsTable .header
{
    text-align:left;
    height:16px;
    position:absolute;
    top:expression(this.offsetParent.scrollTop);
    width: 100%; 
    float: left;
    font-weight:bold;
    z-index:2;
    background-color:#F2F2F2;
}
.NGPMyOpenTicketsTable .header th
{
    background-color:#F2F2F2 !important;
    max-height:14px;
}    
.MyOpenTicketsTable-ActionRequired,
.MyOpenTicketsTable-Title,
.MyOpenTicketsTable-Date
{
    float:none;
}
#OpenTixImageHeader
{
    float: left; 
    height: 100%;
    min-width: 8px;
    max-width:16px;
}    
#OpenTixTitleHeader
{
    float:left;
    min-width:75px;
    text-align:left;
    width:auto;
}    
#OpenTixDateHeader
{
    min-width:65px;
    width:65px;
    max-width:65px;
    *+min-width:85px;
    *+width:85px;
    *+max-width:85px;
    position:relative;
    float:right;
    text-align:left;
}    
.NGPMyOpenTicketsTable .body
{
    height:auto;
    padding:20px 0 0 0;
    *+padding:36px 0 0 0;
    overflow: auto; 
    float: left; 
    width: 100%; 
    overflow-x: hidden; 
    position: relative;
}
.NGPMyOpenTicketsTable .body>tr
{
    position:relative;
    top:16px;
    z-index:1;
}
.NGPMyOpenTicketsRow
{
    height:16px;
    position:static;
    padding:0;
    width: 100%;
}
.MyOpenTicketsTable-ActionRequired
{
    min-width:8px;
}
.MyOpenTicketsTable-ActionRequired img
{
    padding:0 2px;
}    
.MyOpenTicketsTable-Title
{
    width:100%;
    min-width:75px;
}
.MyOpenTicketsTable-Date
{
    width:60px;
    min-width:60px;
    vertical-align:top;
    text-align:left;
    padding-right:8px;
}

Open in new window

<div style="" id="NGPTicketsPanelUpdate"><table width="100%" cellspacing="0" cellpadding="0" class="NGPMyOpenTicketsTable" id="MyOpenTicketsTables"><thead><tr class="header"><th style="width: 8px;" id="OpenTixImageHeader"></th><th id="OpenTixTitleHeader">Title</th><th id="OpenTixDateHeader">Opened</th></tr></thead><tbody class="body"><tr class="NGPMyOpenTicketsRow"><td class="MyOpenTicketsTable-ActionRequired"></td><td class="MyOpenTicketsTable-Title"><a title="esupport: CIO Cases are not displaying.">esupport: CIO Cases are not displaying.</a></td><td class="MyOpenTicketsTable-Date">11-Oct-10</td></tr><tr class="NGPMyOpenTicketsRow"><td class="MyOpenTicketsTable-ActionRequired"></td><td class="MyOpenTicketsTable-Title"><a title="People pages site is not saving the picture that was uploaded">People pages site is not saving the picture that was uploaded</a></td><td class="MyOpenTicketsTable-Date">11-Oct-10</td></tr></tbody></table></div>

Open in new window

0
 
LVL 8

Author Comment

by:MelMc
ID: 35691915
The scroll function would be in the div with ID NGPTicketsPanelUpdate
0
 
LVL 9

Expert Comment

by:BobHavertyComh
ID: 35692098
What exactly would you like NGPTTicketsPanelUpdate to do? What exact scroll behavior would you like??  
0
 
LVL 8

Author Comment

by:MelMc
ID: 35692231
The top:expression(this.offsetParent.scrollTop); keeps the header row in place while the div is scrolled so that you can always see the column headers. This does not work in IE8 and is not good practice, I need to move it to javascript.
0
 
LVL 9

Expert Comment

by:BobHavertyComh
ID: 35692696
If not javascript and you can handle a sroll bar at the bottom of your table body rather than the top then add a css spec for the tbody class of "body". Actually, change this <tbody class="body"> to <tbody class="body1"> as it doesn't seem like a good idea naming a class with the reserved word "body"

Then for your css
.body1
{
    overflow:scroll;
}

0
 
LVL 9

Expert Comment

by:BobHavertyComh
ID: 35692827
Nevermind, doesn't work in IE 9
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 35695760
0
 
LVL 31

Expert Comment

by:James Murrell
ID: 36515742
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
 

Expert Comment

by:samdan john
ID: 41833093
How about this one.
http://pyramidions.com/
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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)
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 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