DIV包装器/居中不能跨浏览器工作

时间:2015-07-11 01:50:31

标签: html css google-chrome internet-explorer firefox

我在包装器中将两个div放在一起。它可以像我在Chrome上设计的那样工作,但它在IE和FF上看起来都很恐怖。我不知道还有什么可以尝试,因为我已经在每个我能想到的地方尝试clear:both;,而且一切看起来仍然很悲惨。请帮忙!谢谢!

网页为:http://www.thorelectriclongboards.com/contact.php

我不知道需要多少,但这是网页的代码:

<html>
    <head>
        <title>Thor Electric Longboards</title>
        <link href='http://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon">
        <link rel="icon" href="img/favicon.ico" type="image/x-icon">
    </head>

<style>
    .title {
        font-weight: 800;
        font-size: 20px;
        background-color: rgba(255, 255, 255, 0.0);
        margin-bottom: 24px;
        text-align: center;
    }
    input[type=submit] {
        background-color: #000080;
        color: white;
        font-size: 16px;
        width: 100%;
        border: none;
        letter-spacing: 3px;
        cursor: pointer;
        padding: 3px;
        margin-top: 8px;
    }
    input[type=text] {
        line-height: 37px;
        border: none;
        width: 100%;
        text-indent: 10px;
        font-size: 18px;
        box-sizing: content-box;
    }
    input[type=email] {
        line-height: 37px;
        border: none;
        width: 100%;
        text-indent: 10px;
        font-size: 18px;
        box-sizing: content-box;
    }
    input:focus {
        outline: none;
    }
    textarea {
        border: none;
        line-height: 20px;
        font-size: 18px;
        resize: none;
        padding-left: 10px;
        padding-top: 5px;
        outline: none;
    }
    .contact {
        text-align: left;
        border-collapse: collapse;
    }
    .lab {
        background-color: #f7941e;
        text-align: right;
        vertical-align: top;
        overflow: auto;
        padding: 10px;
        border: 1px solid #000080;
        border-right: none;
        width: 8%;
        float: left;
        color: white;
    }
    form {
        margin: 0 auto;
        background: transparent;
        width: 50%;
    }
    .table-form {
        border-collapse: collapse;
        width: 27%;
    }
    tr {
        padding-top: 10px;
        padding-bottom: 10px;           
    }
    .spacer {
        padding-top: 6px;
        padding-bottom: 6px;
        background: transparent;
    }
    .side {
        background-color: transparent;
        width: 50%;
        display: inline-block;
        vertical-align: middle;
        white-space: normal;
        letter-spacing: 2px;
    }
    .side > a {
        display: inline-block;
        background-color: transparent;
        vertical-align: middle;
    }
    .contact-img {
        width: 20px;
        height: 20px;
        margin: 15px;
        padding: 12px;
        border: 1px solid #3c5a99;
        opacity: 1;
        transition: opacity .25s ease-in-out;
        -moz-transition: opacity .25s ease-in-out;
        -webkit-transition: opacity .25s ease-in-out;
        background-color: transparent;
    }
    .contact-img:hover {
        opacity: 0.5;
    }
    .wrapper {
        display: inline-block;
        white-space: nowrap;
        background: transparent;
        overflow: hidden;
    }
    label {
        background-color: transparent;
        font-style: italic;
    }
</style>

<body id="background">
    <?php include 'header.html'; ?>
    <div class='main'>
        <div class='title'>CONTACT US USING ANY OF THE OPTIONS BELOW</div>
        <div class='wrapper'>
            <div class='side' style='float:left;'>
                <form id='contact-us' action='' method='POST'>
                    <table class='table-form'>
                        <tr style='border: 1px solid #000080;'>
                            <td class='lab'>NAME</td>
                            <td><input type="text" name='name'></td>
                        </tr>
                        <tr><td class='spacer'></td><td class='spacer'></td></tr>
                        <tr style='border: 1px solid #000080;'>
                            <td class='lab'>EMAIL</td>
                            <td><input type="email" name='email'></td>
                        </tr>
                        <tr><td class='spacer'></td><td class='spacer'></td></tr>
                        <tr style='border: 1px solid #000080;'>
                            <td class='lab'>MESSAGE</td>
                            <td><textarea name='message' rows="6"></textarea></td>
                        </tr>
                        <tr>
                            <td colspan="2"><input type="submit" name='submit' value="SEND"></td>
                        </tr>
                    </table>
                </form>
            </div>
            <div class='side' style='float:right; text-align: left;'>
                <a href='https://www.facebook.com/pages/Thor-Electric-Longboards/1533188433635268' target='_blank'><img class='fb contact-img' src='img/facebook-blue.png' id='fb'></a><label for='fb'>THOR ELECTRIC LONGBOARDS</label><br>
                <a href='https://twitter.com/thorlongboards' target='_blank'><img class='tw contact-img' src='img/twitter-blue.png' id='tw'></a><label for='tw'>@thorlongboards</label><br>
                <a href='https://instagram.com/thor_electric_longboards' target='_blank'><img class='ig contact-img' src='img/instagram-blue.png' id='ig'></a><label for='ig'>THOR_ELECTRIC_LONGBOARDS</label>
            </div>
        </div>          
    </div>
    <?php include 'footer.html'; ?>     
</body>

header.htmlfooter.html中唯一会影响这一点的是:

    .main {
        background-color: rgba(255, 255, 255, 0.7);
        color: #121b1c;
        width: 80%;
        margin: 50px auto;
        padding: 25px;
        overflow: hidden;
        text-align: center;
        border: 1px solid black;
    }

请尽可能帮助!!!

3 个答案:

答案 0 :(得分:1)

看看这是否有帮助:

将此width:100%;添加到.wrapper,然后从float:left;课程中删除.lab

答案 1 :(得分:0)

您的问题不是为包装器定义宽度范围。添加width:100%您的包装类,它应该可以解决问题。

example here

答案 2 :(得分:0)

Floats会阻止元素。因此,table-cell成为block。这打破了桌面。

只需删除

.lab {
  float: left;
}