2016-10-06 52 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