我在媒体查询中的两个兄弟div之间存在间距问题。我无法弄清楚为什么那里有间距。我的white-green
div应该触及arrow-box
div的底部,但出于某种原因,white-green
div显示top: 100px;
div的效果project-input-container
}}
有谁知道为什么会这样?
这就是它的样子:
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;
}
}
答案 0 :(得分:4)
减少以下标记规则的值,并参阅。
$("#myButton").attr("data-value");
答案 1 :(得分:0)
我认为.arrow_box很大。将其更改为高度:自动;
@media screen and (max-width:640px) {
.arrow_box {
width: 100%;
height: auto;
}
答案 2 :(得分: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>