Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help need in tuning my style sheet.

Status
Not open for further replies.

sunw

Technical User
Sep 24, 2007
32
US
Hi, Experts,

I am new to css/dhml. I wrote a piece of css/dhml code which works ok with IE (not perfectly, though), but not work at all with firefox.

Here is my css file – mystyle.css:
Code:
.outterRow {
  background: #996600;
  text-align: center;
  width: 96%;
  margin: 0 auto; /* to center it */
}
DIV.base-layer {
  font-size: 12pt;
  font-weight: bold;
  vertical-align:middle;
  margin: 0.5em 12px;
  padding: 0.5em;
  text-align: left;
  background: transparent;
}
DIV.table-row {
  background: none #ffffcc;
  font-size: 10pt;
  text-align: left;
  padding: 4px 0;
  height: 1.5em;
  clear: both;
  background: transparent;
}
.submitButtons input{
  text-align: center;
  font-weight: bold;
  width: 25%;
}
label.r5 {
  vertical-align: center;
  font-family: arial;
  font-weight: bold;
  font-size: 10pt;
  text-align: center;
  background: transparent;
  width: 20%;
}
.l-container_dark, .l-container_light, .r-container {
  border: none;
  margin: 0;
  padding: 0;
  font-weight: bold;
  width: 49.95%;
  float: left;
}
input.upload_dark, input.upload_light {
  border: solid #cccc66 1px;
  width: 80%;
}
.l-container_dark, input.upload_dark {
  background-color: #777777;
}
.l-container_light, input.upload_light {
  background-color: #AAAAAA;
}
.r-container {
  text-align: center;
  background: #cccc66;
}
Here is my dhtml file:

Code:
<html><head>
<link rel="stylesheet" type="text/css" href="./mystyle.css" />
</head><body>
<form method="post" action="#" enctype="multipart/form-data" name="msf">
<div class="outterRow">
  <div class="base-layer">
    <div class="table-row" id="myid2">
      <div>
        <input name="ml1" class="l-container_dark" type="text" id="ml1ID" />
        <label class="r-container">
          <input name="mkocr1" type="checkbox" value="no" id="mkocr1ID" />
[COLOR=red]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[/color]
          <input name="native1" type="checkbox" value="no" id="native1ID" />
[COLOR=red]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[/color]
          <input name="tiff1" type="checkbox" value="no" id="tiff1ID" />
[COLOR=red]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[/color]
          <input name="ocr1" type="checkbox" value="no" id="ocr1ID" />
[COLOR=red]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[/color]
          <input name="data1" type="checkbox" value="no" id="data1ID" />
        </label>
      </div>
      <div>
        <input name="fname1" class="upload_dark" type="file" id="fnamel1ID" />
      </div>
      <div>
        <input name="ml2" class="l-container_light" type="text" id="ml2ID" />
        <label class="r-container">
          <input name="mkocr1" type="checkbox" value="no" id="mkocr1ID" />
          <input name="native1" type="checkbox" value="no" id="native1ID" />
          <input name="tiff1" type="checkbox" value="no" id="tiff1ID" />
          <input name="ocr1" type="checkbox" value="no" id="ocr1ID" />
          <input name="data1" type="checkbox" value="no" id="data1ID" />
        </label>
      </div>
      <div>
        <input name="fname2" class="upload_light" type="file" id="fname21ID" />
      </div>
    </div>
  </div>
</div>
<div class="outterRow">
  <div class="submitButtons">
    <input type="submit" name=".submit" value="Submit" /> <input type="reset" name=".reset" value="Cancel" />
  </div>
</div>
<div></div>
</form></body></html>

Here are my questions.

1)As I said before, the above code only works ok with IE, but not with Firefox. I appreciate your help in making it work with help. And please also tell me in future, how I can deal with this kind problem? I have found out that sometimes my css file works with IE, but not Firefox. And sometimes it is the other way around. This really drives me nuts. Is there any documentation talking about this issue, i.e. css specs with different browsers?

2)As you may noticed, I added lots of white spaces (actually 21 white spaces) in the first row/right column to make the check boxes evenly spread out. Apparently, it is a dumb way to implement this. And it only works with IE. With Firefox, I only need 14 white spaces. Could someone please show me the correct way to implement this? I'd guess I should make some changes in label.r5 class in the css file. But I don't know how.

3)As you may notice, the left column (an input area) is slightly shorter than the right column (a label area). Is there any fine tuning can be done to make them look the exactly same hight?

Thank you so very much for your help.
 
I can not believe that I made so many typos above. I am sorry about that.

The help I want the most is to make it work with Firefox.

Thanks.

 
First, I would give it a proper Doctype. and then check that it Validates. IE6 will go into quirks mode when it can't find a doctype, and will render stuff as it sees fit, instead of sticking to standards,. Additionally IE6 has a slightly different box model than FF or any other standard compliant browswer.


Once you have done the above, we can address the specific issues.

Choosing a Doctype

W3C Validation Service

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thank you, vacunita, for your inputs.

I did not realize how important the doctype is so I removed it before I posted my codes here. The html page is actually created by perl CGI::pretty.pm. The relevant perl code is like this:

Code:
use CGI::Pretty qw( :html3 );
my $q = new CGI::Pretty;
my $html = $q->start_html(-style=>{src=>'./mystyle.css'});
print $html;

which renders the html doctype like this:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	 "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] lang="en-US" xml:lang="en-US">
<head><link rel="stylesheet" type="text/css" href="./mystyle.css" /></head>

But too bad I can not validate it, because my page is on the intranet only.

Thank you again, for your further advice.
 
Thank you, traingamer, for your help.

I tried again and fixed a few problems. The following is my updated dhtml code:

Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	 "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] lang="en-US" xml:lang="en-US">
<head>
<link rel="stylesheet" type="text/css" href="./mystyle.css" />
</head>
<body>
<form method="post" action="#" enctype="multipart/form-data" name="msf">
<div class="outterRow">
  <div class="base-layer">
    <div class="table-row" id="myid2">
      <div>
        <input name="ml1" class="l-container_dark" type="text" id="ml1ID" />
        <label class="r-container">
          <input name="mkocr1" type="checkbox" value="no" id="mkocr1ID" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="native1" type="checkbox" value="no" id="native1ID" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="tiff1" type="checkbox" value="no" id="tiff1ID" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="ocr1" type="checkbox" value="no" id="ocr1ID" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="data1" type="checkbox" value="no" id="data1ID" />
        </label>
      </div>
      <div>
        <input name="fname1" class="upload_dark" type="file" id="fnamel1ID" />
      </div>
      <div>
        <input name="ml2" class="l-container_light" type="text" id="ml2ID" />
        <label class="r-container">
          <input name="mkocr2" type="checkbox" value="no" id="mkocr2ID" />
          <input name="native2" type="checkbox" value="no" id="native2ID" />
          <input name="tiff2" type="checkbox" value="no" id="tiff2ID" />
          <input name="ocr2" type="checkbox" value="no" id="ocr2ID" />
          <input name="data2" type="checkbox" value="no" id="data2ID" />
        </label>
      </div>
      <div>
        <input name="fname2" class="upload_light" type="file" id="fname21ID" />
      </div>
    </div>
  </div>
</div>
<div class="outterRow">
      <div class="submitButtons">
        <input type="submit" name=".submit" value="Submit" /> <input type="reset" name=".reset" value="Cancel" />
      </div>
</div>
<div></div>
</form></body></html>

The validation output is listed below:
Code:
This page is not Valid XHTML 1.0 Transitional!
Result:  	 Failed validation, 1 Error
Encoding:  	utf-8
Doctype:  	XHTML 1.0 Transitional
Root Element:  	html
Root Namespace:  	[URL unfurl="true"]http://www.w3.org/1999/xhtml[/URL]

Validation Output:  1 Error

   1. Error Line 8, Column 6: end tag for "head" which is not finished.

      </head>

      Most likely, you nested tags and closed them in the wrong order. For example <p><em>...</p> is not acceptable, as <em> must be closed before <p>. Acceptable nesting is: <p><em>...</em></p>

      Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance, in HTML the <head> element must contain a <title> child element, lists (ul, ol, dl) require list items (li, or dt, dd), and so on.

Could this error be a false alarm?

Thanks again for your help.
 
It is probably due to the fact that head requires a title tag to be complete. Yours doesn't. The explanation mentions that.

As for the doctype, it still won't work. IE6 will ignore the doctype if anything appears before it in the output. For you, the xml declaration (which is not needed) is above the doctype and is pushing IE back into quirks mode. You should get rid of the xml declaration to achieve best cross-browser results.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Thank you, Vragabond.

After I added a title tag, my code past the validation.

With regarding to the doctype, as I said before, it was rendered by CGI::pretty.pm. I have no control on it. And more importantly, the html page created by CGI::pretty works <b>FINE</b> with IE, but not working with Firefox. Any clue on this?

Thanks again.
 
It might show FINE in IE6. And if you want to support just IE6, that's fine. If you want to support all other browsers, you need to free the doctype (whatever way you know -- ask in the forum219 how to rig that code to properly display the doctype), break the layout in IE6 to make it similarly broken as all other browsers and then fix that. Until then you will be caught in the endless loop, where fixing it for the others will break it in IE6 and then fixing it in IE6 will break it in all others.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
You are right, Vragabond. My code only works with IE6, not IE7!! I am going to ask for help at perl forum.

Thanks.
 
Surely all you need to do is edit your PERL script so it doesn't output the XML declaration.
That will get you around that first problem.

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top