【发布时间】:2016-08-31 16:26:01
【问题描述】:
我有两个这样的部分:
<section id="achievements"> ... </section>
<section id="services"> ... </section>
它们之间有一个空白区域。虽然我的其余部分并非如此。
我没有为这些部分设置任何显示属性,但它是从 css 文件继承块的显示属性。 (从 Chrome 中的开发者工具中检查)
如果出于某种原因,我还检查了这两个部分的内容。好像不是这样的。
是什么导致了这个空白,我该如何删除它?
PS:如果我应该添加更多信息,请告诉我。
PS2:我在这个网站上查看的帖子谈到了从 inline-block 元素中删除空格。
更新
这里是相关部分的Fiddle:
/* main */
body {
font-family: "Montserrat", sans-serif;
margin: 0px;
padding: 0px;
}
.upper {
text-transform: uppercase;
}
/* Positioning */
.vertically_centered {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.left {
float: left;
}
.right {
float: right;
}
/* For tagline sections in 5 articles */
.tagline {
height: 305px;
padding: 0;
margin: 0;
}
.tagline_text {
margin: auto;
text-align: center;
}
.tagline_sub {
font-size: 18px;
color: #999999;
}
.bottom_line:after {
content: "";
display: block;
width: 60px;
border-bottom: 3px solid #b3b3b3;
margin: 30px auto 40px;
}
/* row 4: achievements */
#achievements,
#achievements article {
height: 320px;
margin: 0px;
padding: 0px;
}
#experiments {
background-color: #1a1a1a;
width: 33.33%;
height: 320px;
}
#awards {
background-color: #212121;
width: 33.33%;
height: 320px;
}
#messages {
background-color: #262626;
width: 33.33%;
height: 320px;
}
.results {
margin: auto;
height: 35%;
width: 75%;
text-align: center;
}
.data_set {
width: 70%;
}
.number {
font-size: 42px;
color: white;
}
.details {
font-size: 16px;
color: #cccccc;
}
.first_icon_set {
max-width: 30%;
height: auto;
}
/* row 5: services */
#services {
background-color: #e6e6e6;
height: 1005px;
margin: 0px;
padding: 0px;
}
#services_details {
height: 700px;
width: 100%;
}
.services_box {
background-color: white;
width: 32%;
height: 330px;
margin: 20px 0.66% 0% 0.66%;
text-align: center;
}
.services_box p {
padding: 0 15px 0 20px;
}
.icon_set_services {
width: 60%;
}
#services_details_sub {
margin-top: 25px;
font-size: 14px;
color: #999999;
line-height: 25px;
}
<div class="">
<!-- row 4: achievements -->
<section class="" id="achievements">
<article id="experiments" class="left">
<section class="results vertically_centered">
<img src="icons/flask.svg" alt="enigma_flask_icon" class="first_icon_set left"></img>
<div class="data_set upper left">
<p class="number">1200</p>
<p class="details">design experiments</p>
</div>
</section>
</article>
<article id="awards" class="left">
<section class="results vertically_centered">
<img src="icons/trophy.svg" alt="enigma_trophy_icon" class="first_icon_set left"></img>
<div class="data_set upper left">
<p class="number">578</p>
<p class="details">awards won</p>
</div>
</section>
</article>
<article id="messages" class="left">
<section class="results vertically_centered">
<img src="icons/envelope.svg" alt="enigma_trophy_icon" class="first_icon_set left"></img>
<div class="data_set upper left">
<p class="number">12489</p>
<p class="details">messages sent</p>
</div>
</section>
</article>
</section>
<!-- Remove white space from top-->
<!-- row 5: services -->
<section id="services">
<article class="tagline">
<section class="tagline_text vertically_centered">
<h2 class="upper bottom_line">Our services</h2>
<p class="tagline_sub">Continuously Creating Daring Digital Solutions</p>
</section>
</article>
<article id="services_details">
<section class="services_box left">
<div class="vertically_centered">
<img src="icons/star.svg" alt="enigma_star_icon" class="icon_set_services"></img>
<h4 class="upper">Great design</h4>
<p id="services_details_sub">Our web design team will spend time with our digital marketing team to ensure the core principles of effective websites.</p>
</div>
</section>
<section class="services_box left">
<div class="vertically_centered">
<img src="icons/files.svg" alt="enigma_files_icon" class="icon_set_services"></img>
<h4 class="upper">Perfect coding</h4>
<p id="services_details_sub">Our web design team will spend time with our digital marketing team to ensure the core principles of effective websites.</p>
</div>
</section>
<section class="services_box left">
<div class="vertically_centered">
<img src="icons/graph.svg" alt="enigma_graph_icon" class="icon_set_services"></img>
<h4 class="upper">Marketing</h4>
<p id="services_details_sub">Our web design team will spend time with our digital marketing team to ensure the core principles of effective websites.</p>
</div>
</section>
<section class="services_box left">
<div class="vertically_centered">
<img src="icons/face.svg" alt="enigma_face_icon" class="icon_set_services"></img>
<h4 class="upper">Support</h4>
<p id="services_details_sub">Our web design team will spend time with our digital marketing team to ensure the core principles of effective websites.</p>
</div>
</section>
<section class="services_box left">
<div class="vertically_centered">
<img src="icons/gear.svg" alt="enigma_gear_icon" class="icon_set_services"></img>
<h4 class="upper">Development</h4>
<p id="services_details_sub">Our web design team will spend time with our digital marketing team to ensure the core principles of effective websites.</p>
</div>
</section>
<section class="services_box left">
<div class="vertically_centered">
<img src="icons/screen.svg" alt="enigma_screen_icon" class="icon_set_services"></img>
<h4 class="upper">Web design</h4>
<p id="services_details_sub">Our web design team will spend time with our digital marketing team to ensure the core principles of effective websites.</p>
</div>
</section>
</article>
</section>
</div>
【问题讨论】:
-
Сan 你做小提琴吗?没有你的风格就很难解决问题
-
好的,给我一些时间,我会做的。谢谢! :)
-
当你不显示大部分 css 时很难知道问题是什么......但我假设这是一个边距或填充问题。
-
请记住,您需要在此处发布显示问题的代码。只要这里也有一个最小的例子,小提琴就可以了。
-
stackoverflow.com/questions/18508442/… 这可能会有所帮助。没有代码就无法识别您的问题
标签: css html whitespace sections