全屏div宽度,体宽有限

时间:2014-03-12 01:38:34

标签: html css

使用shopify模板,其中body的最大宽度为1200像素。 我需要一个div来拥有全屏宽度。你可以理解,我不能删除那个最大宽度,因为它会弄乱整个模板。除了固定的像素宽度之外,还有什么方法吗? 谢谢!

编辑: 不添加html,因为它只是一个div。

@media only screen and (min-width: 1280px)
body {
max-width: 1200px;
margin: 0 auto;
}

#topcontainer {
width:100%;
right:0;
left:0;
height:50px;
background-color:#D8D8D8 !important;
border-bottom: 2px solid #BCBCBD;
z-index:22;
}

3 个答案:

答案 0 :(得分:1)

您可以使用position: absolute; top:0; left: 0; width: 100%; height: 100%的div,或者将CSS应用于<html>

答案 1 :(得分:0)

你想要伸展的元素position: absolute; right: 0; left: 0;会不会有效?没有看到标记和相应的样式很难分辨。也许放在一起快速的jsfiddle。

答案 2 :(得分:-2)

将以下类添加到div

.fullScreen { width:100%; margin:auto; }