1#example1 {
2 background: url(mountain.jpg);
3 background-repeat: no-repeat;
4 background-size: auto;
5}
6
7#example2 {
8 background: url(mountain.jpg);
9 background-repeat: no-repeat;
10 background-size: 300px 100px;
11}
1body {
2 background-position: center;
3 background-repeat: no-repeat;
4 background-size: cover;
5}
1body {
2
3 background-image: url("img_tree.gif");
4
5 background-repeat: no-repeat;
6 background-attachment: fixed;
7
8 background-position: top center;
9 background-size: contain;
10
11 }
1#example1 { /* Example1 has an auto background size */
2 background: url(mountain.jpg);
3 background-repeat: no-repeat;
4 background-size: auto;
5}
6
7#example2 { /* Example2 has an fixed background size */
8 background: url(mountain.jpg);
9 background-repeat: no-repeat;
10 background-size: 300px 100px;
11}
1Background Size is Responsible for Setting a Background picutre in a given
2Contaiener in which you apply that special Background
3
4/* This will make width as static and height as auto */
5/* These three are quite same */
6background-size: 100vw auto;
7background-size: 100%;
8background-size: cover;
9
10
11/* for getting full width and height every time */
12background-size: 100vw 100vh;