CSS3 transition poate fi utilizat pentru a anima proprietatile CSS, adaugand un efect de animatie cand se modifica proprietatile CSS ale unui element HTML, schimband gradual de la un stil la altut.
CSS3 transition are 4 componente:


Pentru a folosi CSS3 transition, trebuie specificate aceste doua lucruri:
      1. Proprietatea CSS la care se aplica efectul ( transition-property ).
      2. Durata efectului ( transition-duration ).
- Ultimele doua componente ( transition-timing-function si transition-delay ) sunt optionale.
- Internet Explorer recunoaste "CSS3 transition" incepand cu IE 10.

Exemplu. Cand mouse-ul e deasupra unui anumit Div, se schimba gradual lungimea.
<style type="text/css"> 
#iddv {
 width:80px;
 height:80px;
 background:#b8b9fe;
 font-size:17px;
 transition-property: width; 
 transition-duration: 1.4s;

/* Firefox 4 */ 
 -moz-transition-property: width;
 -moz-transition-duration: 1.4s;
/* Safari si Chrome */ 
 -webkit-transition-property: width;
 -webkit-transition-duration: 1.4s;
/* Opera */
 -o-transition-property: background-color, color; 
 -o-transition-duration: 1.4s;
}

#iddv:hover {
 width:200px;
}
</style>

<div id="iddv">Pozitionati mouse-ul pe acest patrat.</div>

Demo (Cand cursorul mouse-ului iese din zona elementului, revine gradual la stilul initial):
Pozitionati mouse-ul pe acest patrat.
 

Proprietatea transition prescurtata

Se pot adauga toate cele 4 componente intr-o singura proprietate transition.
Sintaxa:
transition: transition-property transition-duration transition-timing-function transition-delay;
Exemplu: Schimba gradual "font-size" (in 0.4 secunde, cu viteza "ease-out") cand mouse-ul e deasupra unui element cu class="clse".
<style type="text/css"> 
.clse {
 width:150px;
 font-size:13px;
 transition: font-size 0.4s ease-out; 
 -moz-transition: font-size 0.4s ease-out; /* Firefox 4 */ 
 -webkit-transition: font-size 0.4s ease-out; /* Safari si Chrome */
 -o-transition: font-size 0.4s ease-out; /* Opera */
}

.clse:hover {
 font-size: 16px;
}
</style>

<ul>
 <li class="clse"><a href="http://marplo.net/css" title="Curs CSS gratuit">Curs CSS gratuit</a></li>
 <li class="clse"><a href="http://marplo.net/html" title="Curs HTML">Curs HTML</a></li>
 <li class="clse"><a href="http://www.coursesweb.net/" title="Cursuri Programare Web">Cursuri Programare Web</a></li>
</ul>

Demo {plasati cursorul deasupra fiecarui link}:

• Se pot adauga mai multe proprietati pt efect "transition" intr-o singura definitie, separate prin virgula.
Exemplu. Adaugare efect la: background, opacity si transform:
<style type="text/css"> 
.dv1 {
 width:115px;
 height:100px;
 position:relative;
 font-size:17px;
 text-align:center;
 padding-top:18px;
}

.clsdv {
 width:120px;
 height:100px;
 position:absolute;
 top:0;
 left:0;
 background:#b8b9fe;
 transition: background 1.3s, opacity 1.8s, transform 1.4s; 
 -moz-transition: background 1.3s, opacity 1.8s, -moz-transform 1.4s; /* Firefox 4 */ 
 -webkit-transition: background 1.3s, opacity 1.8s, -webkit-transform 1.4s; /* Safari si Chrome */
 -o-transition: background 1.3s, opacity 1.8s, -o-transform 1.4s; /* Opera */
}

.clsdv:hover {
 background: #00da01;
 filter:alpha(opacity=50); /* pt IE */
 opacity:0.5;
 transform:rotate(180deg);
 -moz-transform:rotate(180deg); /* Firefox 4 */
 -webkit-transform:rotate(180deg); /* Safari si Chrome */
 -o-transform:rotate(180deg); /* Opera */
}
</style>

Puneti mouse-ul deasupra acestui dreptunghi.
<div class="dv1">
 <div class="clsdv"></div>
 Text oarecare, ascuns
</div>
Demo:
Puneti mouse-ul deasupra acestui dreptunghi.
 
Text oarecare, ascuns

Proprietati CSS ce pot fi animate

Lista cu proprietati CSS care pot fi utilizate in transition:

- Proprietati pt text:   color, font-size, font-weight, letter-spacing, line-height, text-indent, text-shadow, vertical-align, word-spacing.
- Proprietati pt elemente tip bloc:   background, background-color, background-image, background-position, border-left-color etc., border-spacing, border-left-width etc., clip, crop, height, min-height, max-height, margin-left etc., opacity, outline-width, outline-offset, outline-color, padding-left etc., width, min-width, max-width.
- Proprietati de pozitionare:   bottom, top, left, right, grid-, visibility, z-index, zoom .

Un Test simplu in fiecare zi

HTML
CSS
JavaScript
PHP-MySQL
Engleza
Spaniola
Ce tag se foloseste pentru a adauga liste in elemente <ul> si <ol>?
<dt> <dd> <li>
<ul>
 <li>http://coursesweb.net/html/</li>
 <li>http://www.marplo.net/html/</li>
</ul>
Care valoare a proprietatii "display" seteaza elementul ca tip bloc si afiseaza un punct in fata?
block list-item inline-block
.some_class {
  display: list-item;
}
Care instructiune JavaScript transforma un obiect in sir JSON.
JSON.parse() JSON.stringify eval()
var obj = {
 "courses": ["php", "javascript", "ajax"]
};
var jsonstr = JSON.stringify(obj);
alert(jsonstr);    // {"courses":["php","javascript","ajax"]}
Indicati clasa PHP folosita pentru a lucra cu elemente HTML si XML in PHP.
stdClass PDO DOMDocument
$strhtml = '<body><div id="dv1">CoursesWeb.net</div></body>';
$dochtml = new DOMDocument();
$dochtml->loadHTML($strhtml);
$elm = $dochtml->getElementById("dv1");
echo $elm->nodeValue;    // CoursesWeb.net
Indicati forma de Prezent Continuu a verbului "to live" (a trai /a locui)
lived living liveing
I`m living here.
- Traiesc /Locuiesc aici.
Care este forma de Gerunziu (sau Participiu Prezent) a verbului "vivir" (a trai /a locui)?
vivió vivido viviendo
Estoy viviendo aquí.
- Traiesc /Locuiesc aici.
CSS3 transition

Last accessed pages

  1. Zuma Restaurant (47)
  2. Jocuri Zuma (1483)
  3. Trecutul simplu si continuu - Past Tense Simple and Continuous (1396)
  4. Bubbles3 (3190)
  5. Zilele saptamanii (32)

Popular pages this month

  1. Bubbles3 (3190)
  2. Gramatica limbii engleze - Prezentare Generala (2490)
  3. Prezentul simplu si continuu - Present Tense Simple and Continuous (2259)
  4. Butterfly Kyodai (2024)
  5. Zuma Deluxe (1956)