2016-01-14 67 views
0

我在媒体查询中的两个兄弟div之间有间距问题。我无法弄清楚为什么有间隔。我的white-green div应该触及arrow-box div的底部,但由于某种原因,它似乎white-green div正在从project-input-container中取得top: 100px;的效果。两个div之间的间距问题

有没有人知道为什么会发生这种情况?

这是什么样子:

enter image description here

HTNL

<div class="arrow_box"> 
    <div id="project-content-wrap"> 
    <div id="project-box-title1">KICK START YOUR</div> 
    <div id="project-box-title2">PROJECT</div> 
    <div id="project-box-description">We enjoy partnering with established brands from all over the globe. To begin the process please provide us with a high level overview and submit our form. We will review and respond promptly.</div> 
    </div> 
</div> 

<div class="white-green"> 
    <form action="" autocomplete="on" class="project-input-container"> 
    <input type="text" class="input-borderless" placeholder="Your Name"> 
    <input type="text" class="input-borderless" placeholder="Title/Role"> 
    <input type="email" class="input-borderless" placeholder="Email Address"> 
    <input type="text" class="input-borderless" placeholder="Phone Number"> 
    <input type="text" class="input-borderless" placeholder="Company/URL"> 
    <input type="text" class="input-borderless" placeholder="How did you hear about us?"> 
    <input type="text" class="input-borderless" placeholder="Which of our social media influenced you the most?"> 
    <input type="text" class="input-borderless" placeholder="Human Test: What day comess after Thursday?"> 
    </form> 
</div> 

我正常的桌面代码是这样的:

.arrow_box { 
    position: relative; 
    background-color: rgb(69,186,149); 
    border: 4px solid rgb(69,186,149); 
     width: 33%; 
     height: 800px; 
     z-index: 99; 
} 
.arrow_box:after, .arrow_box:before { 
    left: 100%; 
    top: 50%; 
    border: solid transparent; 
    content: " "; 
    height: 0; 
    width: 0; 
    position: absolute; 
    pointer-events: none; 
} 

.arrow_box:after { 
    border-color: rgba(255, 0, 0, 0); 
     border-left-color: rgb(69,186,149); 
    border-width: 40px; 
    margin-top: -40px; 
} 
.arrow_box:before { 
    border-color: rgba(0, 0, 0, 0); 
    border-left-color: rgb(69,186,149); 
    border-width: 26px; 
    margin-top: -26px; 
} 
#project-content-wrap { 
    margin: 30% 15%; 
} 
#project-box-title1 { 
    font-size: 1.3em; 
    color: #FFF; 
} 
#project-box-title2 { 
    font-size: 6.2em; 
    color: #FFF; 
    margin-top: 20px; 
} 
#project-box-description { 
    font-size: 1.3em; 
    color: #303030; 
    margin-top: 50px; 
    line-height: 1.6em; 
} 
/*-----Input div on project page----*/ 
.white-green { 
    background-color: rgb(241,250,247); 
    width: 66.56%; 
    height: 100%; 
    margin-left: 33%; 
    margin-right: 0; 
    position: absolute; 
    top: 0; 
    right: 0; 
} 
.project-input-container { 
    margin-top: 160px; 
    margin-left: 9%; 

} 
.input-borderless { 
    width: 80%; 
    border-top: 0px; 
    border-bottom: 1px solid green; 
    border-right: 0px; 
    border-left: 0px; 
    background-color: rgb(241,250,247); 
    text-decoration: none; 
    outline: none; 
    display: block; 
    padding: 10px 0; 
    margin: 20px 0; 
    font-size: 1.6em; 
} 

媒体查询:

@media screen and (max-width:640px) { 
.arrow_box { 
    width: 100%; 
    height: 400px; 
} 
.arrow_box:after, .arrow_box:before { 
    top: 100%; 
    left: 50%; 
} 

.arrow_box:after { 
    border-color: rgba(136, 183, 213, 0); 
    border-top-color: rgb(69,186,149); 
    border-width: 30px; 
    margin-left: -30px; 
} 
.arrow_box:before { 
    border-color: rgba(194, 225, 245, 0); 
    border-top-color: rgb(69,186,149); 
    border-width: 36px; 
    margin-left: -36px; 
    margin-top: 0; 
} 
#project-content-wrap { 
    margin: 10% 5%; 
} 
#project-box-title1 { 
    font-size: 1.1em; 
    color: #FFF; 
} 
#project-box-title2 { 
    font-size: 3.2em; 
    color: #FFF; 
    margin-top: 20px; 
} 
#project-box-description { 
    font-size: 1.1em; 
    color: #303030; 
    margin-top: 40px; 
    line-height: 1.6em; 
} 
/*-----Input div on project page----*/ 
.white-green { 
    background-color: rgb(241,250,247); 
    width: 100%; 
    height: auto; 
    /*margin-top: -30px;*/ 
    margin-left: 0; 
    margin-right: 0; 
    margin-bottom: 0; 
    position: relative; 
    right: 0; 
    top: 0; 
} 
.project-input-container { 
    top: 100px; 
    left: 3%; 
    position: relative; 
} 
.input-borderless { 
    width: 90%; 
    border-top: 0px; 
    border-bottom: 1px solid green; 
    border-right: 0px; 
    border-left: 0px; 
    background-color: rgb(241,250,247); 
    text-decoration: none; 
    outline: none; 
    display: block; 
    padding: 10px 0; 
    margin: 20px 0; 
    font-size: 1.2em; 
} 
} 

回答

4

降低以下标记规则的值并查看。

.project-input-container { 
    top: 100px; /*this*/ 
    left: 3%; 
    position: relative; 
} 

.project-input-container { 
    margin-top: 160px; /*this*/ 
    margin-left: 9%; 
} 
+2

特别提示,如果你想的标题是“项目”的大小来响应,你可以视台即'字体大小要这样做:10vmin;'似乎是一个好一个。 – Stickers

+0

em对于响应速度没有效率?出于某种原因,项目的标题只是一点点,这是为什么? – Paul

+2

http://stackoverflow.com/questions/15649244/responsive-font-size – Stickers

0

我认为.arrow_box是很大的。将其更改为高度:auto;

@media screen and (max-width:640px) { 
.arrow_box { 
    width: 100%; 
    height: auto; 
} 
0

有几个问题。我用一些评论更新了你的CSS。结束时修复程序位于@media screen and (max-width:640px) {}

.arrow_box { 
 
    position: relative; 
 
    background-color: rgb(69,186,149); 
 
    border: 4px solid rgb(69,186,149); 
 
     width: 33%; 
 
     height: 800px; 
 
     z-index: 99; 
 
} 
 
.arrow_box:after, .arrow_box:before { 
 
    left: 100%; 
 
    top: 50%; 
 
    border: solid transparent; 
 
    content: " "; 
 
    height: 0; 
 
    width: 0; 
 
    position: absolute; 
 
    pointer-events: none; 
 
} 
 

 
.arrow_box:after { 
 
    border-color: rgba(255, 0, 0, 0); 
 
     border-left-color: rgb(69,186,149); 
 
    border-width: 40px; 
 
    margin-top: -40px; 
 
} 
 
.arrow_box:before { 
 
    border-color: rgba(0, 0, 0, 0); 
 
    border-left-color: rgb(69,186,149); 
 
    border-width: 26px; 
 
    margin-top: -26px; 
 
} 
 
#project-content-wrap { 
 
    margin: 30% 15%; 
 
} 
 
#project-box-title1 { 
 
    font-size: 1.3em; 
 
    color: #FFF; 
 
} 
 
#project-box-title2 { 
 
    font-size: 6.2em; 
 
    color: #FFF; 
 
    margin-top: 20px; 
 
} 
 
#project-box-description { 
 
    font-size: 1.3em; 
 
    color: #303030; 
 
    margin-top: 50px; 
 
    line-height: 1.6em; 
 
} 
 
/*-----Input div on project page----*/ 
 
.white-green { 
 
    background-color: rgb(241,250,247); 
 
    width: 66.56%; 
 
    height: 100%; 
 
    margin-left: 33%; 
 
    margin-right: 0; 
 
    position: absolute; 
 
    top: 0; 
 
    right: 0; 
 
} 
 
.project-input-container { 
 
    margin-top: 160px; 
 
    margin-left: 9%; 
 

 
} 
 
.input-borderless { 
 
    width: 80%; 
 
    border-top: 0px; 
 
    border-bottom: 1px solid green; 
 
    border-right: 0px; 
 
    border-left: 0px; 
 
    background-color: rgb(241,250,247); 
 
    text-decoration: none; 
 
    outline: none; 
 
    display: block; 
 
    padding: 10px 0; 
 
    margin: 20px 0; 
 
    font-size: 1.6em; 
 
} 
 

 
@media screen and (max-width:640px) { 
 
.arrow_box { 
 
    width: 100%; 
 
    height: 400px; 
 
} 
 
.arrow_box:after, .arrow_box:before { 
 
    top: 100%; 
 
    left: 50%; 
 
} 
 

 
.arrow_box:after { 
 
    border-color: rgba(136, 183, 213, 0); 
 
    border-top-color: rgb(69,186,149); 
 
    border-width: 30px; 
 
    margin-left: -30px; 
 
} 
 
.arrow_box:before { 
 
    border-color: rgba(194, 225, 245, 0); 
 
    border-top-color: rgb(69,186,149); 
 
    border-width: 36px; 
 
    margin-left: -36px; 
 
    margin-top: 0; 
 
} 
 
#project-content-wrap { 
 
    margin: 10% 5%; 
 
} 
 
#project-box-title1 { 
 
    font-size: 1.1em; 
 
    color: #FFF; 
 
} 
 
#project-box-title2 { 
 
    font-size: 3.2em; 
 
    color: #FFF; 
 
    margin-top: 20px; 
 
} 
 
#project-box-description { 
 
    font-size: 1.1em; 
 
    color: #303030; 
 
    margin-top: 40px; 
 
    line-height: 1.6em; 
 
} 
 
/*-----Input div on project page----*/ 
 
.white-green { 
 
    background-color: rgb(241,250,247); 
 
    width: 100%; 
 
    height: auto; 
 
    /*margin-top: -30px; <==== remove this =====*/ 
 
    margin-left: 0; 
 
    margin-right: 0; 
 
    margin-bottom: 0; 
 
    position: relative; 
 
    right: 0; 
 
    top: 0; 
 
} 
 
.project-input-container { 
 
    margin-top: 0; /* <==== add this =====*/ 
 
    /* top: 100px; <==== remove this =====*/ 
 
    left: 3%; 
 
    position: relative; 
 
} 
 
.input-borderless { 
 
    width: 90%; 
 
    border-top: 0px; 
 
    border-bottom: 1px solid green; 
 
    border-right: 0px; 
 
    border-left: 0px; 
 
    background-color: rgb(241,250,247); 
 
    text-decoration: none; 
 
    outline: none; 
 
    display: block; 
 
    padding: 10px 0; 
 
    margin: 20px 0; 
 
    font-size: 1.2em; 
 
} 
 
    
 
    /*===== add this =====*/ 
 
    .input-borderless:first-of-type { 
 
    margin-top: 0; 
 
    } 
 
}
<div class="arrow_box"> 
 
    <div id="project-content-wrap"> 
 
    <div id="project-box-title1">KICK START YOUR</div> 
 
    <div id="project-box-title2">PROJECT</div> 
 
    <div id="project-box-description">We enjoy partnering with established brands from all over the globe. To begin the process please provide us with a high level overview and submit our form. We will review and respond promptly.</div> 
 
    </div> 
 
</div> 
 

 
<div class="white-green"> 
 
    <form action="" autocomplete="on" class="project-input-container"> 
 
    <input type="text" class="input-borderless" placeholder="Your Name"> 
 
    <input type="text" class="input-borderless" placeholder="Title/Role"> 
 
    <input type="email" class="input-borderless" placeholder="Email Address"> 
 
    <input type="text" class="input-borderless" placeholder="Phone Number"> 
 
    <input type="text" class="input-borderless" placeholder="Company/URL"> 
 
    <input type="text" class="input-borderless" placeholder="How did you hear about us?"> 
 
    <input type="text" class="input-borderless" placeholder="Which of our social media influenced you the most?"> 
 
    <input type="text" class="input-borderless" placeholder="Human Test: What day comess after Thursday?"> 
 
    </form> 
 
</div>