Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Help with positioning / DIVs
Old 03-23-2009, 08:56 PM Help with positioning / DIVs
tehownererer's Avatar
Novice Talker

Posts: 10
Name: Will
Location: Clinton, Tennessee
Trades: 0
So I've been working on this little self project for my school and I've gotten a pretty good start, i hope

I have 2 problems though, and i have no clue where they can be..

First off, I'm using 2 scrollers made through javascript (i copied and pasted the code and changed it to fit my liking because i don't know a lot of javascript), they are both basically the same, its just one has pictures in it, for a little slideshow, and the other one is used as a substitute for marquee, mostly because w3c does not validate anything with marquee in it..The scrollers look fine in Firefox, however they go way off when in IE. The look / size of the scrollers is formatted through CSS.

The last thing, and its probably a simple newbie mistake, is that there's a big blank space in the top of the site, and I can't figure out why.

I'm kind of new to most of this, so any advice is very much appreciated

Here's the HTML
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="chsstyles.css">
<title>Clinton High School</title>

<script type="text/javascript">

/*Example message arrays for the two demo scrollers*/

var pausecontent=new Array()
pausecontent[0]='<img src="http://www.chs.acs.ac/100th%20birthday/10.jpg" width="250" height="200">'
pausecontent[1]='<img src="http://www.chs.acs.ac/100th%20birthday/4.jpg" width="250" height="200">'
pausecontent[2]='<img src="http://www.chs.acs.ac/100th%20birthday/9.jpg" width="250" height="200">'

var pausecontent2=new Array()
pausecontent2[0]='Announcements Announcements Announcements '
pausecontent2[1]='Announcements Announcements Announcements '
pausecontent2[2]='Announcements Announcements Announcements '

</script>
<script type="text/javascript">

/***********************************************
* Pausing up-down scroller- � Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'<\/div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'<\/div><\/div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

</script>
</head>
<body>
<script type="text/javascript">

//new pausescroller(name_of_message_array, CSS_ID, CSS_classname, pause_in_miliseconds)

new pausescroller(pausecontent, "pscroller1", "someclass", 3000)
document.write("<br />")
new pausescroller(pausecontent2, "pscroller2", "someclass", 4000)

</script>
<div id="maindiv">
<div id="header"><span class="c1">Clinton High School</span><br>
<em><span class="c2">"Commited to High Standards"</span></em><br></div>
<div id="leftcol"><img class="headlogo" src="headlogo.gif" alt="">
<p><a class="leftlink" href="http://www.chs.acs.ac/generalinfo/INFO.htm">General<br>
Information</a></p>
<p><a class="leftlink" href="http://www.chs.acs.ac/chshistory/chshistory.htm">CHS History</a></p>
<p><a class="leftlink" href="http://www.acs.ac/Calendar/Approved%20Calendar%202008-09.pdf">Calendar</a></p>
<p><a class="leftlink" href="http://www.chs.acs.ac/clinton%20high%20misc/CHS_Tutoring_Opportunities_08-09[1].doc">Tutoring<br>
Opportunities</a></p>
<p><a class="leftlink" href="http://www.chs.acs.ac/library/main.htm">Library</a></p>
<p><a class="leftlink" href="http://www.chs.acs.ac/departments/counseling/counselingmain.htm">Counseling</a></p>
<p><a class="leftlink" href="http://www.chs.acs.ac/Staff/STAFFCHS.htm">Staff</a></p>
<p><a class="leftlink" href="http://www.chs.acs.ac/departments/departments.htm">Departments</a></p>
<p><a class="leftlink" href="http://www.chs.acs.ac/activities/CHSactiv.html">Activities</a></p>
<p><a class="leftlink" href="http://www.chs.acs.ac/CHSsports/main.htm">Athletics</a></p>
<p><a class="leftlink" href="http://www.chs.acs.ac/wall%20of%20fame/Wall%20Of%20Fame%20Nomination%20form.doc">CHS Wall of<br>
Fame Form</a></p>
<a href="http://www.acs.ac/"><img src="http://www.chs.acs.ac/library/Pics/acsnew.gif" alt="" class="c4"></a></div>
<div id="content">
<p class="c5">Clinton High School, located in Clinton, Tennessee, is a comprehensive high school serving approximately 1250 students in grades 9-12, is fully accredited by the Southern Association of Colleges and grading periods. The school operates on a block schedule which consists of four 90 minute classes.<br>
<br>
The Clinton High School community fosters a commitment to high standards at all T.I.M.E.S. (Teach, Inspire, Motivate, Empower, Support)</p>
</div>
</div>
</body>
</html>
and here is the External Style Sheet.
Code:
body {
font : 100% Verdana, Arial, Helvetica, sans-serif;
background : black;
margin : 0;
padding : 0;
text-align : center;
color : #000000;
}
#maindiv {
margin-left : auto;
margin-right : auto;
height : 565px;
width : 1000px;
}
img.headlogo {
border : none;
clear : left;
margin-right : 2px;
}
a.leftlink:hover {
color : orange;
font-weight : bold;
}
#header {
background : orange;
width : 88%;
height : 14.5%;
float : right;
}
#leftcol {
background : black;
text-align : left;
border : none;
float : left;
width : 11%;
height : 100%;
}
a.leftlink {
text-align : center;
font-size : 100%;
color : white;
font-style : normal;
text-decoration : none;
overflow : auto;
}
#content {
height : 100%;
background : white;
float : right;
width : 88%;
margin : 0 0 0 0;
}
p.c5 {
font-size : 100%;
font-style : normal;
font-weight : lighter;
text-align : left;
margin-left : 30px;
margin-top : 20px;
}
img.c4 {
border : none;
width : 120px;
}
span.c2 {
color : #333333;
font-size : 150%;
}
span.c1 {
font-size : 200%;
}
#pscroller1 {
border : 0 solid black;
padding : 0;
width : 250px;
height : 200px;
position : absolute;
top : 500px;
left : 600px;
}
#pscroller2 {
width : 872px;
height : 20px;
border : 1px solid black;
padding : 3px;
position : absolute;
top : 100px;
left : 451px;
background : black;
color : white;
text-align : center;
}
#pscroller2 a {
text-decoration : none;
}
Thanks in advance!
tehownererer is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-24-2009, 12:18 AM Re: Help with positioning / DIVs
CWebguy's Avatar
Average Talker

Latest Blog Post:
74 Free Days of TypePad Blog
Posts: 26
Trades: 0
It looks like the javascript is adding the space at the top.

Check out document.write("<br />")

There will always naturally be some space at the top, but not a whole lot (more than about 20px)

Hope this helps.
Lance
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

CWebguy is offline
Reply With Quote
View Public Profile Visit CWebguy's homepage!
 
Old 03-24-2009, 10:40 AM Re: Help with positioning / DIVs
tehownererer's Avatar
Novice Talker

Posts: 10
Name: Will
Location: Clinton, Tennessee
Trades: 0
Ah i see! it seems that the relative positioning in
Code:
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative;
was causing it to go crazy, so i set it to absolute and it took away the extra space.

The other problem is, that the scripts adjust themselves based on the absolute positioning compared to whatever the current resolution is, which is a problem. So if it is 1680 x 1050 and i have it moving left: 500px; then it moves 500px from 1680 pixels, which is a problem. Is there any way I can set it to adjust itself based on a fixed resolution?

I created a site too my problem can become clearer to see.
will.netau.net

Thanks for the help!
tehownererer is offline
Reply With Quote
View Public Profile
 
Old 03-24-2009, 11:23 AM Re: Help with positioning / DIVs
CWebguy's Avatar
Average Talker

Latest Blog Post:
74 Free Days of TypePad Blog
Posts: 26
Trades: 0
Well if you want it to stay fixed regardless (if you are talking left to right) just try setting the margins to auto (left and right) and that should help. If I have a chance to look at your site I will.

Take care.
CWebguy is offline
Reply With Quote
View Public Profile Visit CWebguy's homepage!
 
Old 03-24-2009, 04:30 PM Re: Help with positioning / DIVs
tehownererer's Avatar
Novice Talker

Posts: 10
Name: Will
Location: Clinton, Tennessee
Trades: 0
Still the same problem, and it looks all buggy with IE..
Maybe i should just find a different alternative to marquee, maybe a different script, although this is like the 3rd one I've tried.

Any ideas on how to keep the scrollers fixed? Or should i just use marquee..

Thanks for the help
tehownererer is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help with positioning / DIVs
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.05256 seconds with 12 queries