2016-10-06 59 views
0

内容不会显示在所有,或离开<section>元素周围的空白。部门元素不显示任何内容和/或有空格周围

这是与通过默认设置display: inline-block风格做。所以我试图通过在所有子元素上设置display: block;来覆盖该值,导致<section>根本不显示在网站上。

所以,我该如何把它弄到一起。并删除空白。

下面是摘录:

* { 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 
header, section, footer, aside, nav, article, hgroup { 
 
    display: inline-block; 
 
} 
 
html { 
 
    height: 100vh; 
 
} 
 
body { 
 
    font-family: 'Archivo Narrow', sans-serif;  
 
    width: 100%; 
 
    height: 100vh; 
 
} 
 
html, body { 
 
    overflow: hidden; 
 
} 
 

 
/* Main Content Page */ 
 

 
main { 
 
    width: 100%; 
 
    height: 100vh; 
 
    display: flex; 
 
    flex-wrap: wrap; 
 
    justify-content: center; 
 
} 
 
header { 
 
    width: 100%; 
 
    height: 18vh; 
 
    background-color: orange; 
 
} 
 
aside { 
 
    width: 20%; 
 
    height: 82vh; 
 
    background-color: orange; 
 
} 
 
section { 
 
    width: 79%; 
 
    height: 82vh; 
 
    background-color: darkgrey; 
 
    box-shadow: 5px 5px 5px inset; 
 
}
<main id="content"> 
 

 
<header> 
 
\t <h1>Just a random Header</h1> 
 
</header> 
 

 
<aside> 
 
\t <p>Just alot of Random Text, Just alot of Random Text, Just alot of Random Text, Just alot of Random Text, Just alot of Random Text</p> 
 
</aside> 
 

 
<section> 
 
\t <p>Just alot of Random Text, Just alot of Random Text, Just alot of Random Text, Just alot of Random Text, Just alot of Random Text</p> 
 
\t <p>Just alot of Random Text, Just alot of Random Text, Just alot of Random Text, Just alot of Random Text, Just alot of Random Text</p> 
 
\t <p>Just alot of Random Text, Just alot of Random Text, Just alot of Random Text, Just alot of Random Text, Just alot of Random Text</p> 
 
\t <p>Just alot of Random Text, Just alot of Random Text, Just alot of Random Text, Just alot of Random Text, Just alot of Random Text</p> 
 
</section> 
 

 
</main>

奇怪的是,无论是片段或Codepen显示这个问题,所以这里是一个截图显示的问题,无论是在Firefox和Chrome:

Issue Result

+1

你为什么不离开'宽度:80%'在PaulieD的回答'section'为您刚才的问题? –

+0

在80%离开它意味着

没有在浏览器上都显示,如果你看看上的评论有迹象表明截图,这又是:https://i.imgsafe.org/631ba0d94e.png – Ricky

+0

哦。那是因为'inline-block'。它增加了额外的空白。你可以改变你的HTML,以便在一旁,部分申报单,接连像来的权利之一,所以'

'不“进入”特征线或空格 –

回答

0

上离开width:80% 0和,因为他们是inline-block S,你应该使用一些“技巧”他们

之间移除空白频段例如

  1. </aside><section>。当asides结束,<section>使用注释立即启动,而不断裂线或空格在HTML
  2. </aside><!-- --><section>
  3. 你可以使用的float:left代替display:inline-block
+0

优秀的,我不喜欢选项1的想法他们之间,它的叶子太可怕了标记,选项3我正在考虑,但它可能会导致更多的问题,关于柔性,虽然不确定,所以我选择了选项2,使用HTML注释,<! - 此评论是为了帮助删除之间的空白这些元素: - - >很好很简单,如果另一个开发人员接管它是自我解释的,谢谢。 – Ricky