ubh
01-22-2009, 06:52 AM
Sorry about the title cause I know there must be hundreds of these but I truly am lost hence the title.
I am trying to create an online demonstration/builder of how to create a pure CSS 3 column layout. Problem is that the builder portion of the demonstration throws a error at me in IE and gives some funny results.
Here is the demonstration.
http://www.devinrolsen.com/tools/3column/index.html
In the header you have a text input that allows you to change the left and right column sizes. In IE you enter in your desired numbers and in fact the sizes do change but you get and error. Also after the error the left column is not properly positioned but if you click the "Add Content" button in any of the columns the new size and left columns position are as desired.
Here is my functions that preform the resizing of the columns.
function changeWidth()
{
var cssCode = document.getElementById("cssCode");
var htmlCode = document.getElementById("htmlCode");
cssCode.style.display="none";
htmlCode.style.display="none";
var wrap = document.getElementById("wrap");
var wrapStyle = wrap.getAttribute("style","width");
var left = document.getElementById("left");
var right = document.getElementById("right");
var center = document.getElementById("center");
function appendCSS()
{
var width = document.getElementById("columnWidth").value;
var centerWidth = parseFloat(wrapStyle)-parseFloat(width)-parseFloat(width);
center.style.width=centerWidth+"px";
center.style.marginLeft=width+"px";
center.style.marginRight=width+"px";
left.style.marginLeft="-"+width+"px";
right.style.marginRight="-"+width+"px";
var colWidth = parseFloat(width)-25+"px";
left.style.width=colWidth;
right.style.width=colWidth;
}
if (typeof wrapStyle == 'string') { // what Firefox returns
wrapStyle = wrapStyle.replace(/px/g,"");
wrapStyle = wrapStyle.replace(/width:/g,"");
appendCSS();
}
else if (typeof wrapStyle == 'object') { // what IE returns
wrapStyle = wrapStyle.cssText;
wrapStyle = wrapStyle.replace(/px/g,"");
wrapStyle = wrapStyle.replace(/WIDTH: /g,"");
appendCSS();
}
}
Any help is appreciated and well credited.
I am trying to create an online demonstration/builder of how to create a pure CSS 3 column layout. Problem is that the builder portion of the demonstration throws a error at me in IE and gives some funny results.
Here is the demonstration.
http://www.devinrolsen.com/tools/3column/index.html
In the header you have a text input that allows you to change the left and right column sizes. In IE you enter in your desired numbers and in fact the sizes do change but you get and error. Also after the error the left column is not properly positioned but if you click the "Add Content" button in any of the columns the new size and left columns position are as desired.
Here is my functions that preform the resizing of the columns.
function changeWidth()
{
var cssCode = document.getElementById("cssCode");
var htmlCode = document.getElementById("htmlCode");
cssCode.style.display="none";
htmlCode.style.display="none";
var wrap = document.getElementById("wrap");
var wrapStyle = wrap.getAttribute("style","width");
var left = document.getElementById("left");
var right = document.getElementById("right");
var center = document.getElementById("center");
function appendCSS()
{
var width = document.getElementById("columnWidth").value;
var centerWidth = parseFloat(wrapStyle)-parseFloat(width)-parseFloat(width);
center.style.width=centerWidth+"px";
center.style.marginLeft=width+"px";
center.style.marginRight=width+"px";
left.style.marginLeft="-"+width+"px";
right.style.marginRight="-"+width+"px";
var colWidth = parseFloat(width)-25+"px";
left.style.width=colWidth;
right.style.width=colWidth;
}
if (typeof wrapStyle == 'string') { // what Firefox returns
wrapStyle = wrapStyle.replace(/px/g,"");
wrapStyle = wrapStyle.replace(/width:/g,"");
appendCSS();
}
else if (typeof wrapStyle == 'object') { // what IE returns
wrapStyle = wrapStyle.cssText;
wrapStyle = wrapStyle.replace(/px/g,"");
wrapStyle = wrapStyle.replace(/WIDTH: /g,"");
appendCSS();
}
}
Any help is appreciated and well credited.