项目没有精确地集中在Bootstrap列中 - 再次

时间:2015-09-12 20:15:24

标签: css twitter-bootstrap

最近我询问了here以上的类似案例。

我试图通过上面问题中给出的解决方案来集中项目(在这种情况下)但没有结束。我一直在将这些列包装在一个分开的row col'div'中,但是(这次)没有任何意义。背景中的虚线是真实的中心,显示所有项目(envelope - 图片,CONTACTget in contact - 框,甚至是联系表单和SEND - 按钮)并不完全位于网页的中心。谁可以帮助我摆脱这种不对称?

Codepen

HTML:

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>JFP</title>
    <link rel="stylesheet" href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/bootstrap.css">
        <link rel="stylesheet" href="/static/main.css" >
    <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="/static/app.js"></script>
</head>

<body>
<div class="supporting">
    <div class="container" style="min-height:300px;">

        <div class="col">
            <h1></h1>
            <a>Learn more</a>
        </div>

        <div class="col">
            <img src="http://rexkirby.com/kirbyandson/images/email.svg">
            <h2>Contact</h2>
            <p></p>
            <b>Get in contact</b>
        </div>

        <div class="col">
            <img src="https://s3.amazonaws.com/codecademy-content/projects/broadway/deploy.svg">
            <h2>Support</h2>
            <p></p>
            <div class="interests text-center">
                <a class="learn-more">Learn more</a>
            </div>
            <div class="int text-center" style="display:none">
                <c>Lorem ipsum.</c>
            </div>
            </div>
        </div>
    </div>
</div>

<div class="contactform">
    <div class="container">
        <div class="row col-md-12">

            <div class="col-md-12 text-center">
                <form class="form" id="form1">

                <p class="name">
                <input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input" placeholder="Name" id="name" />
                </p>

                <p class="email">
                <input name="email" type="text" class="validate[required,custom[email]] feedback-input" id="email" placeholder="Email" />
                </p>

                <p class="text">
                <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="Comment"></textarea>
                </p>

                <div class="row col text-center">
                <div class="submit">
                <input type="submit" value="SEND" id="button-blue"/>
                <div class="ease"></div>
                </div>
                </div>
                </form>
            </div>
    </div>
</div>

  </body>

CSS:

body:after {
    content: "";
    position: absolute;
    z-index: -1;
    top: 10%;
    bottom: 0%;
    left: 50%;
    border-left: 2px dotted rgb(51,51,51);
}

.supporting {
    padding-top: 80px;
    padding-bottom: 100px;

}

.supporting .col {
    float: left;
    width: 33%;
    font-family: 'Open Sans', sans-serif;
    text-align: center;
    margin-bottom: 64px;
    padding: 0px 0px;
}

.supporting img {
    height: 40px;
}

.supporting .col h1 {
    font-size: 35px;
    padding-bottom: 48px;
    margin-top: 49px;
}

.supporting h2 {
    font-weight: 600;
    font-size: 23px;
    text-transform: uppercase;
    padding: 0 50px;
    margin-bottom: 60px;
}

.supporting p {
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
}

.supporting a {
    font-size: 10px;
    color: rgb(51,51,51);
    font-weight: 600;
    border: 1px solid rgb(51,51,51);
    padding: 15px 50px;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    position: relative;
}

.supporting b {
    font-size: 10px;
    color: rgb(51,51,51);
    font-weight: 600;
    border: 1px solid rgb(51,51,51);
    padding: 15px 39px;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    position: relative;
}

.supporting .int c {
    font-size: 15px;
    color: rgb(51,51,51);
    height: -10px;
    padding: 0px 50px;
}

.clearfix {
    clear: both;
}

.footer {
    background-color: rgb(51,51,51);
    color: rgb(51,51,51);
    padding: 30px 0;
    margin-top: 30px;
}

.footer p {
    color: rgb(250,250,250);
    font-family: 'Open Sans', sans-serif;
    text-transform: normal;
    font-size: 11px;
    left: -185px;
}


#feedback-page{
    text-align:center;
}

#form-main{
    width:100%;
    float:middle;
    padding-top:0px;
}

#form-div {
    background-color:rgba(72,72,72,0.4);
    padding-left:35px;
    padding-right:35px;
    padding-top:35px;
    padding-bottom:50px;
    width: 450px;
    float: middle;
    left: 50%;
    position: absolute;
    margin-top:30px;
    margin-left: -260px;
    -moz-border-radius: 7px;
    -webkit-border-radius: 7px;
}

.feedback-input {
    color:#3c3c3c;
    font-family: 'Open Sans', sans-serif;
    font-weight:500;
    font-size: 18px;
    border-radius: 0;
    line-height: 22px;
    background-color: rgb(245,245,245);
    padding: 13px 13px 13px 54px;
    margin-bottom: 10px;
    width:100%;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    -ms-box-sizing: border-box;
    box-sizing: border-box;
    border: 3px solid rgba(0,0,0,0);
}

.feedback-input:focus{
    background: #fff;
    box-shadow: 0;
    border: 3px solid rgb(42,186,214);
    color: rgb(51,51,51);
    outline: none;
    padding: 13px 13px 13px 54px;
}

.focused{
    color:#30aed6;
    border:#30aed6 solid 3px;
}

#name{
    background-image: url(http://rexkirby.com/kirbyandson/images/name.svg);
    background-size: 30px 30px;
    background-position: 11px 8px;
    background-repeat: no-repeat;
}

#name:focus{
    background-image: url(http://rexkirby.com/kirbyandson/images/name.svg);
    background-size: 30px 30px;
    background-position: 8px 5px;
    background-position: 11px 8px;
    background-repeat: no-repeat;
}

#email{
    background-image: url(http://rexkirby.com/kirbyandson/images/email.svg);
    background-size: 30px 30px;
    background-position: 11px 8px;
    background-repeat: no-repeat;
}

#email:focus{
    background-image: url(http://rexkirby.com/kirbyandson/images/email.svg);
    background-size: 30px 30px;
    background-position: 11px 8px;
    background-repeat: no-repeat;
}

#comment{
    background-image: url(https://s3.amazonaws.com/codecademy-content/projects/broadway/design.svg);
    background-size: 30px 30px;
    background-position: 11px 8px;
    background-repeat: no-repeat;
}

textarea {
    width: 100%;
    height: 150px;
    line-height: 150%;
    resize:vertical;
}

input:hover, textarea:hover,
input:focus, textarea:focus {
    background-color:white;
}

#button-blue{
    font-family: 'Open Sans', sans-serif;
    float:middle;
    width: 50%;
    border: rgb(51,51,51) solid 1px;
    cursor:pointer;
    background-color: rgb(255,255,255);
    color: rgb(51,51,51);
    font-size: 16px;
    padding-top:12px;
    padding-bottom:12px;
    -webkit-transition: all 0.3s;
    -moz-transition: all 0.3s;
    transition: all 0.3s;
    margin-top:-4px;
    font-weight:600;
    letter-spacing: 1.1px;
}

#button-blue:hover{
    color: rgb(51,51,51);
}

.submit:hover {
    rgb(51,51,51);
}

.ease {
    width: 0px;
    height: 74px;
    background-color: #fbfbfb;
    -webkit-transition: .3s ease;
    -moz-transition: .3s ease;
    -o-transition: .3s ease;
    -ms-transition: .3s ease;
    transition: .3s ease;
}

.submit:hover .ease{
    width:100%;
    background-color:white;
}

@media (max-width: 500px) {
    .main h1 {
        font-size: 50px;
        padding: 0 40px;
    }
    .supporting .col {
        width: 100%;
    }

    #form-div{
        left: 30%;
        margin-right: 3%;
        width: 88%;
        margin-left: 0;
        padding-left: 3%;
        padding-right: 3%;
    }
}

1 个答案:

答案 0 :(得分:1)

您已将“.suporting .col”div的宽度设置为33%,这不是页面的三分之一。如果您选择更精确(例如33.33%),您会发现文本更接近页面的中心位置。 Here是对您的代码的轻微修订。

.supporting .col {
    float: left;
    width: 33.33%;
    font-family: 'Open Sans', sans-serif;
    text-align: center;
    margin-bottom: 64px;
    padding: 0px 0px;
}