Git Product home page Git Product logo

lekce_08's Introduction

Tvořím web A–Z: lekce 8

Jaro 2021, Praha

4. května 2021


Podklady

https://github.com/tvorimweb-2021-praha-jaro/lekce_08


Dnešní cíle

  • Naučit se CSS transformace a předchody (transitions)
  • Seznámit se s tvorbou animací pomocí CSS

Transform ≠ Transition

  • transform = změna tvaru elementu
  • transition = animace přechodu mezi stavy elementu

Transform

CSS vlastnost transform s hodnotami například:

  • translate(x, y)
  • scale(x, y)
  • rotate(deg)
  • skew(deg)
  • ...

Transform - Příklad 1/2

/* Zkosení */
.skew {
  transform: skew(-15deg);
}

/* Otočení */
.rotate {
  transform: rotate(-15deg);
}

note:


Transform - Příklad 2/2

/* Posun */
.translate {
  transform: translate(0, 50%);
}

/* Změna velikosti */
.scale {
  transform: scale(1.5);
}

Transition

CSS vlastnost transition:

  • <property> <duration> <easing> <delay>
  • property: vlastnost, na kterou se transition vstahuje, prázdná znamená všechny
  • duration: délka přechodu (v ms)
  • easing: křivka hodnot v čase
  • delay: zpoždění animace (v ms)

Transition - Příklad

button {
  background-color: blue;
  transition: 300ms;
}

button:hover {
  background-color: red;
}

Transition - Příklad jednotlive vlatnosti 1/2

div {
  /* co se bude animovat */
  transition-property: margin, height, ...;

  /* jakým způsobem se bude animovat */
  transition-timing-function: ease | linear |...;
}

note:


Transition - Příklad jednotlive vlatnosti 2/2

div {
  /* jak dlouho bude animace probíhat */
  transition-duration: 500ms | 0.5s;

  /* jak dlouho se počká než začne průběh */
  transition-delay: 500ms | 0.5s;
}

Transition - Zkrácený zápis

element {
  transition: ([transition-property]) [transition-duration]
    ([transition-timing-function]) ([transition-delay]);
}

Transition - Zkrácený zápis - Příklad

div {
  margin-top: 100px;
  transition: margin-top 300ms ease 1s;
}

div:hover {
  margin-top: 200px;
}

note:

https://css-tricks.com/almanac/properties/t/transition-timing-function/


Animace

  • CSS vlastnost animation:
    • nazev-animace delka [pocet opakovani] [smer] [fillmode]
    • animation-iteration-count - počet opakování nebo infinite
    • animation-direction - normal, reverse, alternate
    • animation-fill-mode - none, forwards, backwards, ...
    • @keyframes nazev-animace
      • from { vychozi stav }
      • to { cilovy stav }
      • X% { stav v daném procentu animace }

Animace - Příklad

.icon {
  animation-name: spin; /* název shodný s názvem za @keyframes */
  animation-duration: 2s; /* trvání animace */
  animation-iteration-count: infinite; /* počet opakování */
  animation-timing-function: linear; /* průběh animace */
}

@keyframes spin {
  from {
    /* výchozí stav prvku */
  }

  to {
    /* koncový stav prvku */
  }
}

Povinný domácí úkol

  • Zadaný v classrooms
  • Ukážeme si co je třeba

Super appka

lekce_08's People

Contributors

macajind avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.