2017-05-09 37 views
1

我嘗試每一個display:,<span>,white-space,overflow:auto等,並在這個網站上搜索了很多。如何消除確實會在這個真正具體的情況下破解換行符。你能告訴我,即使它很簡單嗎? :)如何在特定的環境中消除換行符?

window.onload = function() { 
 
    document.getElementById("container").style.width = screen.width + "px"; 
 
    document.getElementById("container").style.height = screen.height + "px"; 
 

 
}
#container { 
 
    display: block; 
 
    float: left; 
 
    padding: 0px; 
 
    margin: 0px; 
 
    border: 0px; 
 
    background-color: indianred; 
 
    white-space: nowrap; 
 
}
<div id="container"> 
 
</div>

LINE BREAK IMAGE

+1

這就是所謂的 「保證金」,你可以擺脫它與'HTML,身體{填充:0; margin:0;}' –

回答

0

body { margin: 0; }

在你的CSS應該做的伎倆。瀏覽器正在通過它的外觀向主體添加一些默認樣式。

0

這應該工作。

<body style="margin: 0;"> 

body { margin: 0; } 
0

您可以在HTML元素的默認樣式使用normalize.css跨瀏覽器的一致性, 你可以從這裏下載:https://necolas.github.io/normalize.css/ 或者您可以通過CDN添加:

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css">