Differences

This shows you the differences between two versions of the page.

Link to this comparison view

se:labs:01 [2025/10/05 19:35]
ion_irinel.dinu [JavaScript]
se:labs:01 [2025/10/06 20:50] (current)
ion_irinel.dinu [Animations!]
Line 401: Line 401:
 CSS also allows us to animate HTML elements. Let's bring back the photo above: CSS also allows us to animate HTML elements. Let's bring back the photo above:
  
-<​html><​img src='https://​comotion.uw.edu/wp-content/uploads/​2017/​06/​image.jpg' ​class='​animated' ​/></​html>​+<​html><​iframe width="​250"​ height="​250"​ srcdoc=' 
 +<​style>​ 
 +.box { 
 +  width:​100px;​ height:​100px;​ background:#​4a90e2;​ 
 +  animation:​image-animation-example 2s infinite; 
 +
 +@keyframes image-animation-example { 
 +  from {border-radius:​0;​ transform:​scale(1);​ opacity:​1;​} 
 +  50% {border-radius:​100px;​ transform:​rotate(180deg);​ opacity:​0;​} 
 +  to {border-radius:​0;​ transform:​rotate(360deg);​ opacity:​1;​} 
 +
 +body {display:​flex;​ justify-content:center; align-items:​center;​ height:​100vh;​ margin:0; background:#​f4f4f4;​} 
 +</style> 
 +<​div ​class="​box"></​div>​'></iframe> 
 +</​html>​
  
  
-If we take a look at the CSS applied ​to the image, we get a hint on how CSS animations work:+If we take a look at the CSS applied ​inside ​the iframe, we can understand ​how CSS animations work:
  
 <code css> <code css>
-.image-css-example .animated ​+.box 
-  ​animation-nameimage-animation-example+  ​width100px
-  ​animation-duration2s+  ​height100px; 
-  animation-iteration-count: ​infinite;+  background: #4a90e2
 +  animation: image-animation-example 2s infinite;
 } }
  
 @keyframes image-animation-example { @keyframes image-animation-example {
-  from { +  from { border-radius:​ 0; transform: scale(1); opacity: 1; } 
-    ​border-radius:​ 0; +  50% { border-radius:​ 100px; transform: rotate(180deg);​ opacity: 0; } 
-    ​transform: scale(1); +  ​to { border-radius:​ 0; transform: rotate(360deg);​ opacity: 1; }
-    ​opacity: 1; +
-  ​} +
- +
-  50% { +
-    ​border-radius:​ 100px; +
-    ​transform: rotate(180deg);​ +
-    ​opacity: 0; +
-  }+
 } }
 +
 </​code>​ </​code>​
-As you can see, we use a couple of rules: 
  
-  ​''​%%animation-name%%''​ - this tells the browser what animation ​rules to use +As you can see, we use a few key properties:​ 
-  * ''​%%animation-duration%%''​ - this is evident - the duration that the animation ​will run for +  ​* animation-name ​– specifies which animation ​sequence ​to apply 
-  * ''​%%animation-iteration-count%%''​ - this defines the number of times the animation ​will repeat+  * animation-duration ​– defines how long the animation ​lasts (2 seconds in this case) 
 +  * animation-iteration-count ​– controls how many times the animation ​repeats (here, it loops infinitely) 
  
 These three rules are the bare minimum needed in order to add an animation to a HTML element. But we still need to define how the animation will look like. We do this by using a ''​%%@keyframes%%''​ declaration,​ followed by the animation name (the one we set in the ''​%%animation-name%%''​ property). These three rules are the bare minimum needed in order to add an animation to a HTML element. But we still need to define how the animation will look like. We do this by using a ''​%%@keyframes%%''​ declaration,​ followed by the animation name (the one we set in the ''​%%animation-name%%''​ property).
Line 472: Line 481:
 Instead of defining styles in separate CSS files, you apply predefined utility classes directly to your HTML elements. Instead of defining styles in separate CSS files, you apply predefined utility classes directly to your HTML elements.
 What makes Tailwind different? What makes Tailwind different?
 +
 +
 Traditional CSS requires writing custom class names and defining them in a stylesheet. Traditional CSS requires writing custom class names and defining them in a stylesheet.
 For example: For example:
Line 501: Line 512:
 To quickly use Tailwind in a project, include it via CDN in your <​head>​ tag: To quickly use Tailwind in a project, include it via CDN in your <​head>​ tag:
 <code css> <code css>
-<link href="​https://​cdn.jsdelivr.net/​npm/​tailwindcss@3.3.0/dist/​tailwind.min.css"​ rel="​stylesheet"​>+ <script src="​https://​cdn.jsdelivr.net/​npm/​@tailwindcss/browser@4"><​/script>
 </​code>​ </​code>​
 +Now we can use tailwind css classes:
 <code css> <code css>
 <div class="​min-h-screen flex flex-col items-center justify-center bg-gray-100">​ <div class="​min-h-screen flex flex-col items-center justify-center bg-gray-100">​
Line 508: Line 520:
   <p class="​text-gray-700 text-lg">​This layout was built without a single line of CSS.</​p>​   <p class="​text-gray-700 text-lg">​This layout was built without a single line of CSS.</​p>​
 </​div>​ </​div>​
- 
 </​code>​ </​code>​
 +=== Tailwind in 100 seconds ===
 +<​HTML>​
 +<iframe width="​560"​ height="​315"​ src="​https://​www.youtube.com/​embed/​mr15Xzb1Ook?​si=BbGRJ9mz_8yLkP9A"​ title="​YouTube video player"​ frameborder="​0"​ allow="​accelerometer;​ autoplay; clipboard-write;​ encrypted-media;​ gyroscope; picture-in-picture;​ web-share"​ referrerpolicy="​strict-origin-when-cross-origin"​ allowfullscreen></​iframe>​
 +</​HTML>​
 +
 +=== Why use Tailwind? ===
 +Tailwind offers speed, consistency,​ and simplicity. It allows designers and developers to work faster, maintain cleaner projects, and focus more on building — not styling.
  
 ===== JavaScript ===== ===== JavaScript =====
Line 539: Line 557:
   * Semicolons in JavaScript are optional. We recommend using something like [[https://​github.com/​sheerun/​prettier-standard|prettier-standard]] paired with an editor such as [[https://​code.visualstudio.com/​|Visual Studio Code]] when developing in JavaScript.   * Semicolons in JavaScript are optional. We recommend using something like [[https://​github.com/​sheerun/​prettier-standard|prettier-standard]] paired with an editor such as [[https://​code.visualstudio.com/​|Visual Studio Code]] when developing in JavaScript.
  
-We will delve deeper into JavaScript in the lab.+We will delve deeper into JavaScript in the next lab.
  
 === jQuery is not JavaScript === === jQuery is not JavaScript ===
Line 555: Line 573:
 **Task 1**  -  Modify the //​task.css//​ file from {{:​se:​labs:​task1.zip|Task 1}} to make the human do something (e.g. jump). **Task 1**  -  Modify the //​task.css//​ file from {{:​se:​labs:​task1.zip|Task 1}} to make the human do something (e.g. jump).
  
-**Task 2**  -  Create a personal page and host it using GitHub Pages. Here are two examples of personal pages: +**Task 2**  -  Modify the //​task2.html// ​ from  {{:​se:​labs:​task2_tailwind.zip|Task 2}}  and center a box (div) on the screen using three different Tailwind approaches. 
-  * [[https://www.cosmindumitrache.com/|Example1]] + 
-  * [[https://juokaz.com/​|Example2]]+**Task 3**  -  Create a personal page and host it using GitHub Pages. Here are two examples of personal pages: 
 +  * [[https://geocushen.com|Example1]] 
 +  * [[https://www.taniarascia.com/​|Example2]]
  
 ====== Feedback ====== ====== Feedback ======
se/labs/01.1759682104.txt.gz · Last modified: 2025/10/05 19:35 by ion_irinel.dinu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0