2015-11-18 20 views
-2

我想知道您是否可以让您的站点保持相同的大小,因此当您在更大的屏幕上查看站点时,它只会为页面增加更多空间/背景。HTML让站点始终具有相同的大小

(我不希望媒体查询,以便当屏幕变得更大风格变化)

+0

您可以通过设置静态的宽度和高度为你的主要元素做到这一点很容易。但是,这不是一个好方法,因为它会使您的网站在大屏幕上显得太小,或在小屏幕上显得太大。 – Arashsoft

回答

1

使用CSS,你可以居中你的主要股利(包装)。

#wrapper { 
 
    width: 500px; 
 
    
 
    margin: 0 auto; 
 
    
 
    background: green; 
 
} 
 
body { 
 
    margin: 0px; 
 
    font-family: Arial; 
 
} 
 

 
#wrapper { 
 
    width: auto; /* You can set the width here, but if you want to make the page smaller on smaller devices you use 'auto' here. */ 
 
    max-width: 500px; /* Set the maximum width of the webpage. */ 
 
    margin: 0 auto; /* Center the wrapper */ 
 
    background: green; 
 
    color: white; 
 
}
<body> 
 
    <div id="wrapper"> 
 
    <h1>Welcome to your webpage.</h1> 
 
    <h2>Site content goes here.</h2> 
 
    </div> 
 
</body>

+0

这回答了这个问题。 – KeineMaster

+0

Thanx为您的答案。 –

相关问题