将图像拉伸为完整尺寸作为背景图像

时间:2015-08-12 18:03:21

标签: html css

尝试将图像完全拉伸(使其覆盖整个页面)作为部分的背景。背景大小有什么区别:封面和100%100%

<section class="starter"></section>

.starter
{
background-image:url("C:/Users/Rakesh/Desktop/Medium v1.3/Section.jpg");
background-size:cover;
background-repeat:repeat-x;
height: 100%;
width: 100px; 
min-height: 100%;
}

2 个答案:

答案 0 :(得分:0)

看这篇文章: https://css-tricks.com/perfect-full-page-background-image/

html { 
background: url(images/bg.jpg) no-repeat center center fixed; 
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

答案 1 :(得分:0)

background-size:100% 100%

导致图像拉伸和填充

background-size:cover

使图像保持纵横比和裁剪

http://jsfiddle.net/pkrf1b5f/