我目前正在使用居中的包装器(以margin 0 auto为中心)。现在我想要一个从左侧开始的容器,直到居中的包装器开始。使用这个给定的保证金规格,这可能吗?
我真的很感激一些提示!
另见小提琴:http: //jsfiddle.net/TQhEa/1/
我现在拥有的:
我想拥有的:
我的代码:
<body>
<div id="page-wrapper">
<p><---- how can i cover the left side only with red without javascript but keeping the "0 auto margin?"
</div>
</body>
我的CSS:
body, html{
width:100%;
height:100%;
top:0;
margin:0;
background-image: url('http://www.art-wallpaper.net/Full-Size-HD-Wallpaper29/images/HD%20Widescreen%20Wallpaper%2059.jpg');
background-repeat:no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#page-wrapper{
background-color:red;
margin: 0 auto;
width: 400px;
top:0;
margin-top:0;
height:100%;
}
p {
padding:0;
margin:0;
font-size:30px;
}
}