Solved

Div doesn't resize until page refresh - CSS

Posted on 2009-07-10
8
678 Views
Last Modified: 2012-05-07
Hi. I am using a javascript text scroller which in turn scrolls text within a DIV element. The DIV is specified using CSS:

#pscroller1
{
width: 95%;
height: 15%;
padding: 5px;
overflow: visible;
border: 0px solid #000000;
}

My problem is that when the window is made smaller/bigger, the div doesn't change its' size until the page is refreshed. Anyone know how to do this automatically?
0
Comment
Question by:chris_smith_51
8 Comments
 
LVL 18

Expert Comment

by:Eternal_Student
ID: 24821461
You mean the browser window right?

If you have set the width as a percentage then it should re-size automatically. Do you have something I could look at to see this problem in more detail?
0
 
LVL 19

Expert Comment

by:NerdsOfTech
ID: 24821509
replace <html> with:

newer browsers should allow for auto width based on %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

Open in new window

0
 
LVL 2

Author Comment

by:chris_smith_51
ID: 24822246
@Eternal_Student:

Yes, I mean the browser window.

See www.csgshow.org for what I'm talking about. The scroller is in the upper-left corner of the page beneath the main links.
0
 
LVL 19

Expert Comment

by:NerdsOfTech
ID: 24823200
use fixed height
#pscroller1

{

width: 95%;

height: 200px;

padding: 5px;

overflow: visible;

border: 0px solid #000000;

}

Open in new window

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 2

Author Comment

by:chris_smith_51
ID: 24829835
unfortunately the problem still exists....
0
 
LVL 19

Expert Comment

by:NerdsOfTech
ID: 24832110
If it is the scrolling link area... then your ID# is wrapper or wrapper2 NOT #pscroller :)

Style.css

I added #wrapper

#wrapper
{
width: 95%;
height: 200px;
padding: 5px;
overflow: visible;
border: 0px solid #000000;
}


you could also revert to %

#wrapper
{
width: 95%;
height: 15%;
padding: 5px;
overflow: visible;
border: 0px solid #000000;
}
html, body, ul, li, h1, h2, h3, h4 {

	margin: 0;

	padding: 0;

	list-style: none;

}

img {

	border: 0;

}

a {

	color: #333;

	font-weight: bold;

	text-decoration: none;

}

a:hover {

	color: #f00;

}
 

.expansionSelected {

	color: #f00;

	font-weight: bold;

	text-decoration: none;

}
 

.expansionNotSelected {

	color: #333;

	font-weight: bold;

	text-decoration: none;

}
 

.left {

	float: left;

}

.right {

	float: right;

}

body 

{

	background: url('../Images/Construction/header_bg.jpg') repeat-x top left;

	text-align: center;

	font: 12px arial, sans-serif;

}

#wrapper {

	text-align: left;

	margin: auto;

	width: 100%;

}

#wrapper2 {

	text-align: left;

	margin: auto;

	width: 95%;

}

#logo {

	background: url('../Images/Construction/logo.gif') no-repeat top left;

	height: 78px

}

#logo h1 {

	color: #FD2E00;

	font-weight: normal;

	font-size: 28px;

	padding: 20px 0 0 90px;

	margin: 0;

}

#logo p {

	color: #333333;

	padding: 0 0 0px 90px;

	margin: 0;

	font-size: 16px;

}

#sectionLinks {

	background: url('../Images/Construction/header_c_bg.gif') repeat-x;

	position: relative;

	height: 370px

}

#sectionLinks a {

	color: #E7E4E4;

	text-decoration: none;

}

#sectionLinks a:hover {

	color: #fff;

	text-decoration: none;

}

#sectionLinks ul {

	padding: 70px 0 0 382px;

	margin: 0;

	position: relative;

	z-index: 1;

}

#sectionLinks li {

	background: url('../Images/Construction/bullet.gif') no-repeat left center;

	margin: 0; padding-left:30px; padding-right:0; padding-top:10px; padding-bottom:8px

}

#sectionLinks li#m1 { margin-left: 19px; }

#sectionLinks li#m2 { margin-left: 9px; }

#sectionLinks li#m3 { margin-left: 3px; }

#sectionLinks li#m4 { margin-left: 0px;  }

#sectionLinks li#m5 { margin-left: 2px; }

#sectionLinks li#m6 { margin-left: 8px; }

#sectionLinks a { font-weight: normal; }

#search {

	margin: 15px 0 0 400px;

}

#search h3 {

	color: #000000;

	font-weight: normal;	

}

#search a {

	color: #1c4c96;

	font-weight: bold;

	text-decoration: none;

}

#search a:hover {

	color: #f00;

}

#mainImage {

	background: url('../Images/Construction/header.jpg') no-repeat;

	position: absolute;

	top: 0;

	left: 0;

	width: 382px;

	height: 370px

}

#mainImageCorner {

	background: url('../Images/Construction/header_pip.jpg') no-repeat;

	position: absolute;

	top: 0;

	left: 382px;

	width: 48px;

	height: 94px			

}

#body {

	width: 100%;

}

#body-inner {

	padding: 23px 23px 8px 23px;

}

#body hr {

	color: #999999;

	height: 1px;

}

#body h2 {

	color: #FF0000;

}

#body h3 {

	color: #1c4c96;

}

#body-left {

	float: left;

	width: 30%;

}

#body-center {

	float: left;

	width: 30%;

}

#body-right {

	float: right;

	width: 34%;

}

#body-nav {

	float: left;

	width: 20%;

}

#body-main {

	float: right;

	width: 77%;

}

#body-main a {

	color: #1c4c96;

	font-weight: bold;

	text-decoration: none;

}

#body-main a:hover {

	color: #f00;

}

#body-left ul {

	margin: 30px 55px;

}

#body-left li {

	margin: 5px;

}

#separator {

	float: left;

	width: 3%;

	display: block;

}

#body-right .box {

	padding: 15px;

	background: #fff;

	border: 1px solid #999;

	margin: 2em 0;

}

#body-right .box p {

	margin: 0 0 1em 0;

}

#body-right .box .left {

	margin-right: 10px;

	border: 0px solid #999;

}

#body-right .box .button {

	text-align: right;

	padding-top: 0px;

	position: relative;

}

.button a {

	border-left:2px solid #9C2828; border-right:2px solid #650000; border-top:2px solid #E68282; border-bottom:2px solid #650000; background:#CC0000 url('../Images/Construction/btn.gif') repeat-y left; color: #fff;

	font-weight: normal;

	position: relative; padding-left:20px; padding-right:15px; padding-top:3px; padding-bottom:3px

}

.button a:hover {

	background-color: #EF1818;

	color: #fff;

}

#copyright-bar {

	background: url('../Images/Construction/footer_bg.gif') repeat-x;

	width: 100%;

	margin-top: 10px;

	clear: both;

}

#copyright-text {

	margin-top: 20px;

	padding-bottom: 10px;

	width: 33%;

	margin-bottom: 10px;

	font-size: 11px;

	float: left;

	display: inline;

	text-align: center;

}

#copyright-text1 {

	margin-top: 20px;

	padding-bottom: 10px;

	width: 33%;

	margin-bottom: 10px;

	font-size: 11px;

	float: left;

	display: inline;

	text-align: center;

}

#copyright-text2 {

	margin-top: 20px;

	padding-bottom: 10px;

	width: 33%;

	display: inline;

	float: left;

	margin-bottom: 10px;

	font-size: 11px;

	text-align: center;

}

#navigation {

	margin-top: 7px;

	width: 100%;	

	font-size:90%;

}

#navigation ul {

	list-style: none;

	margin: 0;

	padding: 0;

}

#navigation li a  {

	display: block;

	padding: 5px 5px 5px 0.5em;

	border-left: 7px solid #809fff;

	border-right: 1px solid #809fff;

	border-bottom: 1px solid #809fff;

	background-color: #bfcfff;

	color: #00248f;

	text-decoration: none;

}

#navigation li a:hover {

	background-color: #809fff;

	color: #00248f;

}

#navigation ul ul {

	margin-left: 12px;

}

#navigation ul ul li {

	margin:0;

	background-color: #bfcfff;

	color: #00248f;

}

#navigation ul ul a:link, #navigation ul ul a:visited {

	background-color: #bfcfff;

	color: #002485;

}

#navigation ul ul a:hover {

	background-color: #809fff;

	color: #00248f;

}

.breadcrumb {

	font-weight:bold;

}

#pscroller1

{

width: 95%;

height: 15%;

padding: 5px;

overflow: visible;

border: 0px solid #000000;

}
 

#wrapper

{

width: 95%;

height: 200px;

padding: 5px;

overflow: visible;

border: 0px solid #000000;

}
 

.someclass{

}

Open in new window

0
 
LVL 42

Accepted Solution

by:
David S. earned 50 total points
ID: 24833267
It seems to me that the problem is the scroller script itself. This line sets the width of the elements to a fixed width when the script initializes.

this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"

Try adding the following code block after this line:

new pausescroller(pausecontent, "pscroller1", "someclass", 5800)
window.onresize = function(){

  var tickerid = "pscroller1";
 

  tickerdiv=document.getElementById(tickerid);
 

  visiblediv=document.getElementById(tickerid+"1");
 

  hiddendiv=document.getElementById(tickerid+"2");
 

  visibledivtop=parseInt(pausescroller.getCSSpadding(tickerdiv));
 

  //set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
 

  visiblediv.style.width=hiddendiv.style.width=tickerdiv.offsetWidth-(visibledivtop*2)+"px";

}

Open in new window

0
 
LVL 2

Author Closing Comment

by:chris_smith_51
ID: 31602555
excellent! thanks :)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now