Web Technologies

CSS #3

Claudia Chiriță . 2026/2027

CSS LAYOUT: multicolumns

  • allows arranging content on several columns, like in a newspaper
  • essentially, a container with property column-count or column-width
column-count: number of columns;
column-width: the size of a column;

multicol

  • properties for styling a multicol layout:
column-gap: the space between columns
column-span: how many columns an element is occupying;
column-rule: the style of the line diving the columns;
/* shorthand   column-rule: column-rule-style
               column-rule-width column-rule-color */

CSS across devices

  • adapting the layout of a web page to different user devices:
    mobile (phone, tablet) & computer

Adaptive/Mobile Friendly Design
vs.
Responsive Web Design

Adaptive design

  • the server app detects the device of the user and responds with different pages
  • ex: webpage.com vs. m.webpage.com

Responsive Design

  • a single version of the page that works on any device

  • advantages:
    • easier to mentain
    • SEO friendly
    • possibility to share the same URL between different devices

Media queries

  • applying a CSS style depending on the general type of a device or other characteristics such as screen resolution or browser width
  • conditionally applying a style using @media and @import rules
  • specifying media for elements such as <style>, <link>, <source> using the media= attribute
  • for accesibility

Media queries

media type: screen, print, speech
media features: width, height, max-height, max-width, 
                orientation, resolution, aspect-ratio

media query syntax:

media type and (med-feature1:val) and (med-feature2:val)...

Media queries HTML

  • media HTML attribute
  • using different CSS styles depending on the properties of the media device
<head>
  
  
</head>

Media queries CSS

  • CSS at-rule @media
    @media media-query1, media-query2 { }

example:

@media screen and (max-width: 960px) and (min-width: 500px)
{
   body { background-color: pink; }
}

@media operators

and, only, not, and ","

  • only used for older browsers that don't recognize it, the css code inside the media query being ignored
    @media only x is equivalent to @media x
  • the "," operator acts as a disjunction

Viewport

<head>
    
</head>

tells the browser that the page should be scaled
to fit the screen size

relative measuring units

  • length units relative to the dimension of the parent element / of the font of the parent element, or the viewport dimension
  • ex: em, rem, vw, vh, vmin, vmax

responsive Text

  • using the viewport length units
    (vw, vh, vmin, vmax)

responsive Text

  • using media queries

responsive images

  • the img, video, iframe elements do not inherit the change of dimension

responsive images

responsive images

displaying different images for different dimensions; using html elements <picture> and <source>


   
   
   image

responsive background images

background-image: url(adresă-imagine);
background-size: cover;
/* the image covers the entire container*/

FLASH QUIZ: ALIGNING

horizontal centering

FLASH QUIZ: ALIGNING

to the right!

FLASH QUIZ: ALIGNING

vertical centering

Transforms

CSS Transforms

  • changing the position and the shappe of the content of an HTML element without affecting the normal flux of the document
  • affine linear transformations of the elements (box model)
  • rotation, scaling, translation, skewing in the plane and 3D

Transform

transform: method(values); 

  • 2D transform methods:
    translate(), rotate(), scale(), skew(), matrix()
  • list of transforms separated by spaces; the transforms are applied one at a time
  • transform-origin
    specifies the position of the origin

Transform: translate

transform: translate(tx,ty)
           translateX(tx), translateY(ty); 

moves the element from the initial position, according to the given parameters: [X-axis] and [Y-axis]

Transform: rotate

transform: rotate(degree); 

rotates the element clockwise if the value (degrees) is positive and counter-clockwise if the value is negative

Transform: scale

transform: scale(sx,sy),
           scaleX(sx), scaleY(sy); 

enlarges or shrinks the dimensions of the element depending on the given parameters sx and sy

Transform: skew

transform: skew(ax,ay),
           skewX(ax), skewY(ay); 

distorts the element along X and Y axis according to the specified parameters

Transform

we can apply several transforms to an element at the same time

Accessibility

  • scaling/zooming animations can raise accessibility issues; they can cause migraines or seizures
  • adding controls for stopping animations in a web page is recommended
  • using the media feature prefers-reduced-motion
    is recommended

3D Transforms

  • extensions of 2D transforms
  • 3D effect obtained using the property
    perspective (distance on the Z axis)
translateZ(tz) -> translate3d(tx,ty,tz)
rotateZ(az) -> rotate3d(x,y,z,grade)
scaleZ(sz) -> scale3d(sx,sy,sz)
matrix3d(n,n,...,n)
perspective(n)

Transitions

  • controlling the animation speed at which the value of a CSS property changes: the change can take place during a period of time, not just instantaneously
  • triggered by events
    :hover, :focus, :active

Transitions

necessary properties for defining a transition:

transition-property: the CSS property to be changed;
transition-duration: s; /* duration of transition */
transition-timing-function: linear; /* ease, ease-in, 
                       ease-out, step-start, step-end 
                       (predefined functions) */
transition-delay: s; /* waiting time before the  
                        start of the transition */
                        
transition: property  duration  timing-function  delay;

properties to which we can apply transitions

Transitions

CSS Animations

  • consist of two components:
    • a style defining the animation
    • a set of keyframes that indicate the initial and final states of the animation and possible intermediary points

Keyframes

@keyframes name-animation {
   0% {...}
   25% {...}
   ...
   75% {...}
   100% {...}
}

@keyframes name-animation {
   from {...} /* equivalent to 0% */
   to {...}   /* equivalent to 100% */
}

Animation

animation-name: nume-animation;
animation-duration: s; /* mandatory */
animation-timing-function: linear /*ease, ease-in, ease-out*/
animation-delay: s;
animation-iteration-count: val; /* infinite */
animation-direction:normal /* alternate, reverse */
animation-fill-mode: none /* forwards, backwards, both */

Animation

The BRB

The BRB

The BRB

The BRB

The BRB

              .     .
             (>\---/<)
             ,'     `.
            /  q   p  \
           (  >(_Y_)<  )
            >-' `-' `-<-.
           /  _.== ,=.,- \       questions?
          /,    )`  '(    )
         ; `._.'      `--<
        :     \        |  )
        \      )       ;_/ 
         `._ _/_  ___.'-\\\
            `--\\\