CSS需要注意的知识点

1,CSS背景样式设置
给body标签指定背景图,这样背景图就可以填充整个浏览器viewport了。其实,该方案对所有的块级容器都可以生效。块级容器的宽高是动态的,那么背景图将自动伸缩,充满整个容器。CSS body标签的样式如下:body {/* 加载背景图 /background-image: url(images/background-photo.jpg);/ 背景图垂直、水平均居中 /background-position: center center;/ 背景图不平铺 /background-repeat: no-repeat;/ 当内容高度大于图片高度时,背景图像的位置相对于viewport固定 /background-attachment: fixed;/ 让背景图基于容器大小伸缩 /background-size: cover;/ 设置背景颜色,背景图加载过程中会显示背景色 */background-color: #464646;}

例如:

#body {
    width: 100%;
    border: 2px solid red;
    background: url(${pageContext.request.contextPath}/img/timg.gif) no-repeat;
    /* 背景图垂直、水平均居中 */
    background-position: center center;
    /* 让背景图基于容器大小伸缩 */
    background-size: cover;
    overflow:hidden;
}

2,让div水平垂直居中的几种方法 - 杜少博客 - 博客园 https://www.cnblogs.com/dushao/p/5999239.html

猜你喜欢

转载自blog.csdn.net/flower_CSDN/article/details/81370057