CSS3 contine trei proprietati noi pt. background: background-size, background-origin, si background-clip, de asemenea, puteti adauga mai multe imagini pentru fundalul unui element, si chiar sa folositi culori gradient, cu linear-gradient.
<style type="text/css"><!--
#id1 {
width:200px;
height:100px;
border:1px solid blue;
background:url('css3.jpg');
background-size:100px 60px;
background-repeat:no-repeat;
}
#id2 {
width:300px;
height:120px;
border:1px solid #01da02;
background:url('css3.jpg');
background-size:contain;
background-repeat:no-repeat;
}
#id3 {
width:300px;
height:120px;
border:1px solid silver;
background:url('css3.jpg');
background-size:cover;
}
--></style>
<div id="id1">Curs CSS gratuit - dimensiuni in pixeli</div>
<div id="id2">www.coursesweb.net - valoare contain</div>
<div id="id3">www.marplo.net - valoare cover</div>
Rezultat:


<style type="text/css"><!--
#id1 {
width:300px;
height:120px;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#dafeda', endColorstr='#0308fe'); /* IE 7, 8 */
background-image: -ms-linear-gradient(top left, #01fe02, #0102fe); /* IE10 */
background: -moz-linear-gradient(top left, #1f1, #fff, #11f); /* Mozilla Firefox */
/* Safari, Chrome */
background-image: -webkit-gradient(linear, left top, right bottom, color-stop(0, #0f1), color-stop(0.5, #fff), color-stop(1, #01f));
background-image: -o-linear-gradient(top left, #01fe02, #0102fe); /* Opera 11.1+ */
background: linear-gradient(top left, #1f1, #fff, #11f); /* W3C Markup */
}
--></style>
<div id="id1">Curs gratuit CSS<br />
www.marplo.net</div>
Rezultat:
<style type="text/css"><!--
#id1 {
width:300px;
height:120px;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#dafeda', endColorstr='#0308fe'); /* IE 7, 8 */
background-image: -ms-linear-gradient(top, #01fe02 0%, #0102fe 99%); /* IE10 */
background: -moz-linear-gradient(top, #1f1 0%, #fff 65%, #11f 99%); /* Mozilla Firefox */
/* Safari, Chrome */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #0f1), color-stop(0.6, #fff), color-stop(1, #01f));
background-image: -o-linear-gradient(top, #01fe02 0%, #0102fe 99%); /* Opera 11.1+ */
background: linear-gradient(top, #1f1 0%, #fff 65%, #11f 99%); /* W3C Markup */
}
--></style>
<style type="text/css"><!--
#id1 {
width:350px;
height:120px;
padding:20px;
border:3px solid blue;
background:url('css3.jpg');
background-repeat:no-repeat;
background-color:#bcfede;
background-origin:content-box;
}
#id2 {
width:350px;
height:120px;
padding:20px;
border:3px solid blue;
background:url('css3.jpg');
background-repeat:no-repeat;
background-color:#bcfede;
background-origin:border-box;
}
--></style>
<div id="id1">Pozitioneaza imaginea in background incepand de la continut</div>
<div id="id2">Pozitionare relativa la bordura</div>
Rezultat:
<style type="text/css"><!--
#id1 {
width:350px;
height:120px;
padding:20px;
border:2px solid blue;
background-color:#cdfeda;
background-clip:padding-box;
-webkit-background-clip:padding-box; /* Safari */
}
#id2 {
width:350px;
height:120px;
padding:20px;
border:2px solid blue;
background-color:#cdfeda;
background-clip:content-box;
-webkit-background-clip:content-box; /* Safari */
}
--></style>
<div id="id1">background-clip cu padding-box</div>
<div id="id2">background-clip cu content-box</div>
Rezultat:
<style type="text/css"><!--
#id1 {
width:400px;
height:150px;
background-image: url('html_course.jpg'), url('css3.jpg');
background-repeat: no-repeat, repeat-x;
background-position: center top, center bottom;
}
--></style>
<div id="id1">Imagini multiple de background</div>
Rezultat: