水平和垂直居中DIV
有没有办法垂直和水平地居中DIV,但重要的是,当窗口小于内容时,内容不会被切割 .div必须具有背景颜色和宽度和高度。
我总是将div与绝对定位和负边距居中,就像在提供的示例中一样。但它存在的问题是它会削减内容。有没有一种方法可以在没有这个问题的情况下使div .content居中?
我在这里有一个例子:http://jsbin.com/iquviq/1/edit
CSS:
body { margin: 0px; }.background {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: yellow;}/* 
is there a better way than the absolute positioning and negative margin to center the div .content: div with background color a width and a hight?: 
*/ .content {
    width: 200px;
    height: 600px;
    background-color: blue;
    position:absolute;
    top:50%;
    left:50%;
    margin-left:-100px;/* half width*/
    margin-top:-300px;/* half height*/}HTML:
<div class="background"> <div class="content"> some text </div></div>
我的问题不是“如何水平和垂直居中一个元素?”的问题.1我之前曾问过我的问题。(只是查看日期)。2-我的问题非常清楚,并以黑色为条件:“当窗口小于内容时,内容不会被删除”
BIG阳
					白板的微信
随时随地看视频慕课网APP