1、全屏背景:
html,body{
width:100%;
height:100%
}
body {
display: block;
background-image: url(“images/bg.jpg”);
background-size: 100% 100%;
margin: 0;
padding: 0;
border: none;
outline: none;
}
2、absolute居中:
width: 95%;
height: 95%;
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
margin: auto;
另外如需居中偏上,可以:
position: absolute;
height:20px;
width:20px;
top: -5px;right: 0;bottom: 0;left: 0;
margin: auto;
3、body默认宽度是100%,高度是默认是0,很多情况下需要js设定body的高度为window.screen.height;
如需全屏背景图,也可以设置html,body{width:100%;height:100%;}
4、显示省略号效果, “white-space: nowrap”规定忽略元素内部的换行符.
white-space: nowrap;
width: 100px;
overflow:hidden;
text-overflow:ellipsis;
截断显示:
white-space: nowrap;
overflow:hidden;
text-overflow:clip;
“`