Set the size of the background image, displayed as length value or percentage, also Images can be retracted using cover and contain.
Syntax:
background-size: auto | <长度值> | <百分比> | cover | contain
Value description:
1. auto: Default value, does not change the original height and width of the background image;
2.
4. cover: As the name suggests,
covers, that is, The background image is scaled to to fill the entire container; 5. contain: Contain, that is, the background image is scaled to
one side close to the container To the edge. Tips: You can enter your own code in the editing window on the right to try out the effects of different values.
<!DOCTYPE html><html><head> <meta charset="utf-8"><title>背景图片大小</title><style type="text/css">.demo { background: url(http://static.mukewang.com/static/img/logo_index.png) no-repeat; width: 300px; height: 140px; border: 1px solid #999; background-size:cover;}</style> </head> <body><div class="demo"></div></body></html>