表单的跨浏览器兼容性问题

时间:2011-01-27 08:09:43

标签: html css google-chrome internet-explorer-8 webforms

我编写了一份客户信息表,但在IE 8,Chrome和Firefox中看起来有所不同。我希望它以相同的方式在所有三个浏览器中显示,如下所示。 ![在此输入图像说明] [1]

下图显示了其他浏览器的外观

[1])Chrome

![在此输入图片说明] [2]

[2])IE 8兼容模式 ![在此输入图像说明] [3]

这是我的HTML代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org

/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Web System</title>
<link href="css/layout.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <div id="header">

        <div id="headerTop">
          <p>&nbsp;</p>
          <p>&nbsp;</p>
        </div>

        <div id="headerBottom"></div>
    </div>

    <div id="wrapper">
        <div id="flags"></div>
        <div id="topLine"></div>

        <div id="information">
            <div id="welcomeText">Welcome  ADMIN, CB002813</div>
            <div id="menuSearchText">Menu Search</div>
            <div id="menuSearchTextbox"><input type="text" id="menuSearch" name="menuSearch" /></div>
            <div id="searchIcon"></div>
            <div id="helpIcon"></div>
            <div id="helpText">Help</div>
            <div id="logoutIcon"></div>
            <div id="logoutText">Logout</div>
        </div>

        <div id="navigation">
            <div id="reservations"></div>
            <div id="rentals"></div>
            <div id="tariffs"></div>
            <div id="fleet"></div>
            <div id="tools"></div>
            <div id="reports"></div>
            <div id="systemManagement"></div>
            <div id="navigationRepeat"></div>
        </div>

        <div id="customerForm">
            <div id="customerHeader"></div>
            <form>
                <div id="firstLine">
                    <div id="customerNo">Customer No.</div>
                    <input type="text" name="customerNoText" id="customerNoText" size="13" />
                    <div id="title">Title</div>                    
                        <select id="titleCombo">
                            <option value="selectTitle"></option>
                            <option value="mr">Mr.</option>
                            <option value="mrs">Mrs.</option>
                            <option value="ms">Ms.</option>
                        </select>                  
                </div>
                <div id="secondLine">
                    <div id="firstName">First Name</div>
                    <div id="firstNameMandatory"></div>
                    <input type="text" id="firstNameText" name="firstNameText" size="13"/>
                    <div id="middleName">Middle Name</div>
                    <input type="text" id="middleNameText" name="middleNameText" size="13"/>
                    <div id="lastName">Last Name</div>
                    <div id="lastNameMandatory"></div>
                    <input type="text" id="lastNameText" name="lastNameText" size="13"/>
                    <div id="searchIcon2"></div>
                </div>
                <div id="thridLine">
                    <div id="delivery">Delivery</div>
                    <select id="deliveryCombo">
                        <option value="selectDelivery">Select</option>
                        <option value="document">Document</option>
                        <option value="nonDocument">Non Document</option>
                    </select>
                    <div id="collection">Collection</div> 
                    <select id="collectionCombo">
                        <option value="selectCollection">Select</option>
                        <option value="small">Small</option>
                        <option value="large">Large</option>
                    </select>
                </div>
                <div id="fourthLine">
                    <div id="flightNo">Flight No.</div>
                    <input type="text" id="flightNoText" name="flightNoText"  size="5"/>
                    <select id="flightNoCombo">
                        <option value="selectFlightNo"></option>
                        <option value="ul209">UL 209</option>
                        <option value="ul211">UL 211</option>
                    </select>
                    <div id="terminal">Terminal</div>
                    <input type="text" id="terminalText" name="terminalText" size="13"/>
                </div>
                <div id="fifthLine">
                    <div id="specialServices">Special Services</div>
                    <select id="specialServicesCombo">
                        <option value="selectSpecialServices"></option>
                        <option value="plane">Plane</option>
                        <option value="ship">Ship</option>
                        <option value="taxi">Taxi</option>
                    </select>
                    <div id="raType">RA Type</div>
                    <select id="raTypeCombo">
                        <option value="selectRaType"></option>
                        <option value="a">A</option>
                        <option value="b">B</option>
                    </select>
                </div>
            </form>
        </div>

        <div id="bottomLine"></div>

        <div id="footer">
            <div id="footerText1">Terms and Conditions | Contact Us</div>
            <div id="footerText2">Copyright © 2010. All rights reserved. Software by EVES IT Lanka (Pvt) Ltd.</div>
            <div id="w3cLogo"></div>
        </div>

    </div>
</body>
</html>

这是我的CSS

* {
    margin: 0px;
    padding: 0px;
}
#header #headerBottom {
    background-image: url(../images/header_part2.gif);
    background-repeat: repeat-x;
    height: 6px;
    width: auto;
}
#wrapper #flags {
    background-image: url(../images/flags.gif);
    height: 37px;
    width: 960px;
    background-color: #FFF;
    background-position: 777px;
    background-repeat: no-repeat;
}
#header #headerTop {
    background-image: url(../images/header_part1.gif);
    background-repeat: repeat;
    height: 185px;
    background-position: center;
}
#wrapper #topLine {
    background-image: url(../images/line.gif);
    background-repeat: no-repeat;
    background-position: center;
    height: 5px;
    width: 960px;
}
#wrapper #informationTop #informationLeft {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    text-decoration: none;
    float: left;
    margin-left: 34px;
    margin-top: 12px;
}
#wrapper {
    background-color: #FFFFFF;
    width: 960px;
    margin-right: auto;
    margin-left: auto;
    border-right-width: 1px;
    border-left-width: 1px;
    border-right-style: double;
    border-left-style: double;
    border-right-color: #CCC;
    border-left-color: #CCC;
}
#wrapper #informationTop #informationRight #informationRightIcon {
    background-image: url(../images/help_icon.gif);
    height: 20px;
    background-repeat: no-repeat;
    float: left;
    width: 637px;
    margin-top: 7.5px;
    background-position: 617px;
}
#footer {
    margin-bottom: auto;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    text-align: center;
    padding: 10px;
}
#wrapper #footer #w3cLogo {
    background-image: url(../images/w3c_logo.gif);
    height: 31px;
    width: 960px;
    background-repeat: no-repeat;
    background-position: center;
    margin-top: 10px;
}
#wrapper #bottomLine {
    background-image: url(../images/line.gif);
    height: 5px;
    width: 960px;
    margin-top: 736px;
    background-repeat: no-repeat;
    background-position: center;
}
#wrapper #loginContainer #loginContainerMain form {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    line-height: 30px;
    padding-top: 43px;
    margin-left: 56px;
    margin-right: 40px;
    margin-bottom: 68px;
}
#wrapper #informationTop #informationRight #informationRightText {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    font-weight: bold;
    float: right;
    margin-top: 12px;
    margin-right: 22px;
}
body {
    background-color: #FFFFFF;
    background-image: url(../images/background.gif);
    background-repeat: repeat-x;
}
#wrapper #information #welcomeText {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    float: left;
    margin-left: 34px;
    margin-top: 14px;
}
#wrapper #information #menuSearchText {
    float: left;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    font-weight: bold;
    margin-left: 330px;
    margin-top: 14px;
}
#wrapper #navigation {
    background-color: #06C;
    height: 36px;
    width: 960px;
    clear: both;
}
#wrapper #information #helpText {
    float: left;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    font-weight: bold;
    margin-top: 13px;
    margin-left: 5px;
}
#wrapper #information #logoutIcon {
    background-image: url(../images/logout_icon.gif);
    float: left;
    height: 23px;
    width: 24px;
    margin-top: 8px;
    margin-left: 10px;
    margin-bottom: 12px;
}
#wrapper #information #logoutText {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    font-weight: bold;
    float: right;
    margin-top: 13px;
    margin-right: 17px;
}
#wrapper #information #menuSearchTextbox #menuSearch {
    float: left;
    margin-top: 9px;
    margin-left: 10px;
}
#wrapper #navigation #reservations {
    background-image: url(../images/reservation_button.gif);
    height: 36px;
    width: 86px;
    float: left;
}
#wrapper #navigation #rentals {
    background-image: url(../images/rental_button.gif);
    height: 36px;
    width: 124px;
    float: left;
}
#wrapper #navigation #tariffs {
    background-image: url(../images/tariff_button.gif);
    height: 36px;
    width: 59px;
    float: left;
}
#wrapper #navigation #fleet {
    background-image: url(../images/fleet_button.gif);
    float: left;
    height: 36px;
    width: 64px;
}
#wrapper #navigation #tools {
    background-image: url(../images/tools_button.gif);
    height: 36px;
    width: 56px;
    float: left;
}
#wrapper #navigation #reports {
    background-image: url(../images/reports_button.gif);
    float: left;
    height: 36px;
    width: 71px;
}
#wrapper #navigation #systemManagement {
    background-image: url(../images/systemManagement_button.gif);
    height: 36px;
    width: 135px;
    float: left;
}
#wrapper #navigation #navigationRepeat {
    background-image: url(../images/navigation_repeat.gif);
    width: 365px;
    height: 36px;
    float: right;
    background-position: right;
    background-repeat: repeat-x;
}
#wrapper #navigation {
    border: 1px solid #adb09d;
}

#wrapper #information #searchIcon {
    background-image: url(../images/search_icon.gif);
    height: 16px;
    width: 16px;
    float: left;
    margin-left: 14px;
    margin-top: 13px;
}
#wrapper #information #helpIcon {
    background-image: url(../images/help_icon.gif);
    height: 20px;
    width: 20px;
    float: left;
    margin-top: 10px;
    margin-left: 26px;
}
#wrapper #customerForm {
    height: 226px;
    width: 682px;
    margin-top: 53px;
    margin-left: 11px;
    border: 1px solid #F30;
}
#wrapper #customerForm #customerHeader {
    background-image: url(../images/customer_header.gif);
    height: 18px;
    width: 682px;
    background-position: center;
    background-repeat: no-repeat;
}
#wrapper #customerForm form #firstLine {
    height: 22px;
    width: 682px;
    margin-top: 39px;
}
#wrapper #customerForm form #secondLine {
    height: 22px;
    width: 682px;
    margin-top: 6px;
}
#wrapper #customerForm form #thridLine {
    height: 22px;
    width: 682px;
    margin-top: 6px;
}
#wrapper #customerForm form #fourthLine {
    height: 22px;
    width: 682px;
    margin-top: 6px;
}
#wrapper #customerForm form #fifthLine {
    height: 22px;
    width: 682px;
    margin-top: 6px;
}
#wrapper #customerForm form #firstLine #customerNoText {
    float: left;
    margin-left: 9px;
}
#wrapper #customerForm form #thridLine #delivery {
}
#wrapper #customerForm form #firstLine #titleCombo {
}
#wrapper #customerForm form #fifthLine #specialServices {
}

#wrapper #customerForm form #firstLine #customerNo {
    float: left;
    margin-left: 46px;
}
#wrapper #customerForm form #firstLine #title {
    float: left;
    margin-left: 70px;
    margin-right: 10px;
}
#wrapper #customerForm form #secondLine #firstName {
    float: left;
    margin-left: 60px;
}
#wrapper #customerForm form #secondLine #middleName {
    float: left;
    margin-left: 19px;
}
#wrapper #customerForm form #secondLine #firstNameMandatory {
    background-image: url(../images/mandatory_icon.gif);
    height: 8px;
    width: 8px;
    float: left;
}

#wrapper #customerForm form #secondLine #LastName {
    float: left;
}
#wrapper #customerForm form #secondLine #firstNameText {
    float: left;
    margin-left: 3px;
}
#wrapper #customerForm form #secondLine #middleNameText {
    float: left;
    margin-left: 10px;
    margin-right: 22px;
}
#wrapper #customerForm form #secondLine #lastNameMandatory {
    background-image: url(../images/mandatory_icon.gif);
    height: 8px;
    width: 8px;
    float: left;
}

#wrapper #customerForm form #secondLine #lastName {
    float: left;
}
#wrapper #customerForm form #secondLine #lastNameText {
    float: left;
    margin-left: 3px;
}
#wrapper #customerForm form #secondLine #searchIcon2 {
    background-image: url(../images/search_icon.gif);
    height: 16px;
    width: 16px;
    float: left;
    margin-left: 5px;
}
#wrapper #customerForm form #thridLine #delivery {
    float: left;
    margin-left: 77px;
}
#wrapper #customerForm form #thridLine #deliveryCombo {
    float: left;
    margin-left: 11px;
    width: 105px;
}
#wrapper #customerForm form #thridLine #collection {
    float: left;
    margin-left: 36px;
}
#wrapper #customerForm form #thridLine #collectionCombo {
    float: left;
    margin-left: 10px;
    width: 105px;
}
#wrapper #customerForm form #fourthLine #flightNo {
    float: left;
    margin-left: 70px;
}
#wrapper #customerForm form #fourthLine #flightNoText {
    float: left;
    margin-left: 10px;
}
#wrapper #customerForm form #fourthLine #flightNoCombo {
    float: left;
    width: 49px;
}
#wrapper #customerForm form #fourthLine #terminal {
    float: left;
    margin-left: 38px;
}
#wrapper #customerForm form #fourthLine #terminalText {
    margin-left: 15px;
}

#wrapper #customerForm form #fifthLine #specialServices {
    float: left;
    margin-left: 30px;
}
#wrapper #customerForm form #fifthLine #specialServicesCombo {
    float: left;
    width: 105px;
    margin-left: 11px;
}
#wrapper #customerForm form #fifthLine #raType {
    float: left;
    margin-left: 42px;
}
#wrapper #customerForm form #fifthLine #raTypeCombo {
    margin-left: 14px;
    width: 105px;
}

#wrapper #customerForm form {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}

所以有人可以指导我下一步该做什么吗? ............我认为这就是全部。

3 个答案:

答案 0 :(得分:4)

您应该使用CSS来设置字段的宽度,而不是使用size属性。此外,根据用户代理,<input><select>元素可能使用与传统W3C“内容框”模型不同的盒子模型。

您可以使用以下CSS在所有浏览器上调整输入大小,包括IE:

input, select {
   width: 105px;
   -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
   -moz-box-sizing: border-box;    /* Firefox, other Gecko */
   box-sizing: border-box;         /* Opera/IE 8+ */
}

这将强制所有输入使用边框模型(Quirks IE Model)并确保所有浏览器的输入大小相同。

答案 1 :(得分:2)

您需要使用CSS为INPUT字段指定宽度,而不是使用size=..属性。并非所有浏览器都尊重最大允许内容和元素大小的size属性。

所以而不是

<input type="text" size="7">

你需要像

这样的东西
<input type="text" style="width: 150px;">

(外部文件中的CSS包含其他所有内容,而不是像示例中的内联。)

答案 2 :(得分:0)

也许你会发现浏览器的CSS黑客有点用处:http://paulirish.com/2009/browser-specific-css-hacks/

它允许您为特定浏览器编写单独的CSS规则,这可能是某些情况下唯一的解决方法。