SlideShare uma empresa Scribd logo
1 de 24
DISPLAYING GRAPHICS AND CSS3
ANIMATIONS
SESSION 7
Aptech Computer Education
Presented by Muhammad Ehtisham Siddiqui (BSCS)
1
Objectives
 Explain graphic formatting in Web pages
 Explain graphic insertion, sizing, and padding
 Explain CSS3 Animation
 Describe the use of CSS3 on mobile devices
Presented by Muhammad Ehtisham Siddiqui (BSCS)
2
Introduction of Graphics and Animations
Presented by Muhammad Ehtisham Siddiqui
(BSCS)
3
 CSS3 has allowed the designers to style their Web pages
graphically with ease.
 HTML5 applications provide amazing experiences with the use of
new CSS3 animations.
 The introduction of mobile applications has allowed the users to
expand their Web usage to mobile devices.
 CSS3 has introduced new features specifically for mobile
devices.
Graphic Format
Presented by Muhammad Ehtisham Siddiqui
(BSCS)
4
 There are many graphic formats available; the most commonly used
are Joint Photographic Experts Group (JPEG), Graphics
Interchange Format (GIF), and Portable Network Graphics (PNG).
 Some graphic format are as follows.
Format Description
Color Depth It is defined by the number of distinct colors that are
represented by a hardware or software. Color depth is defined
by the number of bits per pixel (bpp) and it is also called as bit
depth. Higher the color depth indicates higher range of colors
used.
Compression/fi
le size
Graphic files are large, so images are compressed using
various techniques. Compression stores the original images in
a reduced number of bytes using an algorithm. This image can
be expanded back to the original size using a decompression
algorithm. In some compression formats, images with less
complexity results in smaller compressed file sizes.
Types of Compression(File Size)
Presented by Muhammad Ehtisham Siddiqui
(BSCS)
5
 The two types of image file compression algorithms used are as
follows:
 Lossless compression
 In this algorithm, file size is reduced but preserves a copy of the
original uncompressed image. Lossless compression avoids
accumulating stages of re-compression when editing images.
 Lossy compression
 In this algorithm, a representation of the original uncompressed image
is preserved. The image appears to be a copy of the original image but
in actuality it is not a copy. Lossy compression achieves smaller file
sizes when compared with lossless compression. Generally, lossy
compression algorithms allow variable compression that comprises on
image quality for file size.
Graphical Formats
Presented by Muhammad Ehtisham Siddiqui
(BSCS)
6
 Animation
 Some graphic format consists of a series of frames that are played one
after the other giving an impression of animation. Animated graphics are
typically used on a Web page to attract visitor’s attention.
 Transparency
 It is very common on the Web to display an image on a Web page that
appears directly against the background color of the page. The background
color of the Web page shows through the transparent portion of the image.
In a transparent image, one and only one color can be hidden. If the color
chosen to make transparent is same as the background of the inserted
image, then an irregularly shaped image appears to float on the page.
Figure 7.2 shows a transparent image.
Graphic Format for the Web
Presented by Muhammad Ehtisham Siddiqui
(BSCS)
7
 For Web pages, use of JPEG and PNG graphics are recommended as it
provides maximum compatibility with all the devices that might be
accessing the Web page. For photos, use of JPEG graphic format and for
screen-shots and drawings use of PNG graphic format is recommended.
Both these formats compress the picture information to reduce the
download time and increase the downloading speed.
 JPEG
 It uses a lossy compression which means that the image quality is lost in the process
of compressing the image. It is recommended that for continuous tone pictures such
as photos JPEG should be used. If the quality is reduced, then the loss is visible;
JPEG is about half the size of PNG.
 PNG
 It uses lossless compression, which means there is no loss of any image detail.
PNG was designed for transferring images on the Internet and not for professional-
quality print graphics; therefore it does not support non-RGB color spaces such as
CMYK. It supports high color and partial transparency using alpha channels.
Graphic Format for the Web
Presented by Muhammad Ehtisham Siddiqui
(BSCS)
8
 GIF
 It uses a lossless compression which means that there is no loss in quality when the image is
compressed. The uncompressed image stores its information in a linear fashion. Each line of
pixels is read from left to right. An interlaced GIF file stores the lines of the image in a different
order. Animated graphics are stored in gif format.
Graphic Insertion
Presented by Muhammad Ehtisham Siddiqui
(BSCS)
9
 The IMG element is an empty element, which allows the user to
insert an image in a Web page.
 It allows insertion of images and diagrams. The commonly used
graphic formats that are supported are namely, GIF, JPEG, BITMAP
(BMP), and PNG.
 The <img> tag reserves a space for the image and does not insert
the image in the HTML page. It creates a link between the image and
the HTML page.
 The common attributes of IMG elements are as follows.
Attributes Description
Src Specifies the path of an image that is to be displayed.
Height Specifies the height of an image.
Width Specifies the width of an image.
Figure Tag <figure>
Presented by Muhammad Ehtisham Siddiqui
(BSCS)
10
 HTML5 introduced a new <figure> tag.
 The <figure> tag acts as a container containing the <img> tag.
 In other words, it is not a replacement for <img> tag, but acts as a container into
which the <img> tag is placed.
 The <figure> tag specifies self-contained content, such as illustrations, diagrams,
photos, code listings, and so on.
 Code:
<figure>
<img src=”logo.gif” style=”float: left” width=”304” height=”228” />
</figure>
Figure Caption tag <figcaption>
Presented by Muhammad Ehtisham Siddiqui
(BSCS)
11
 The <figcaption> tag allows the user to add a caption to the image. The
caption always appears along with the image even if the image floats in
Web site layout.
 Code:
<figure>
<img src=”flower1.jpg”>
<img src=”flower2.jpg”>
<img src=”flower3.jpg”>
<figcaption>The different types of flowers</figcaption>
</figure>
CSS Image Sizing/ Padding
Presented by Muhammad Ehtisham Siddiqui
(BSCS)
12
 SIZE
 Size of an image is specified in pixels.
 The height and width property sets the height and width of the image.
 One can specify the width and the height will be resized or vice versa.
 CODE:
p.ex {
height:100px;
width:100px;
}
CSS Image Sizing/ Padding
Presented by Muhammad Ehtisham Siddiqui
(BSCS)
13
 PADDING
 The CSS padding property is used to specify the space between the element
border and the element content.
 It is used to separate them from the surrounding element.
 The background color of the element affects the padding property.
 Using separate properties such as top, right, bottom, and left, different padding
values can be specified and the padding can be changed separately.
 CODE
 padding-top:10px;
 padding-bottom:10px;
 padding-right:15px;
 padding-left:15px;
 CODE
 padding:25px 50px 75px 100px;
Thumbnail Graphics
Presented by Muhammad Ehtisham Siddiqui
(BSCS)
14
 The speed of loading a page of a Web site is reduced if high-resolution
graphics are used.
 High-resolution graphics are required to improve the effectiveness of the site
and cannot be avoided.
 Hence, to avoid this issue, thumbnails are used.
 A thumbnail is a small image, or a part of a larger image.
 Clicking the thumbnail image will link to the larger original image, which can be
viewed and downloaded.
 Even a hover effect can be given through CSS and JavaScript.
Thumbnails
Presented by Muhammad Ehtisham Siddiqui (BSCS)
15
 Code
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
img { border: 1px solid #ddd;
border-radius: 4px;
padding: 5px;
width: 150px; }
img:hover {
box-shadow: 0 0 2px 1px ; }
</style>
</head>
<body>
<h2>Thumbnail Image</h2>
<p>Click on the image to enlarge it.</p>
<a target="_blank" href="img_forest.jpg">
<img src="img_forest.jpg" alt="Forest" style="width:150px">
</a>
</body>
</html>
Transition Support
Presented by Muhammad Ehtisham Siddiqui (BSCS)
16
CSS 3 Transitions
Presented by Muhammad Ehtisham Siddiqui (BSCS)
17
 Interactivity is one of the important aspects of animation.
 Earlier, a combination of HTML, CSS, and JavaScript were used to
animate objects on the Web.
 In 2007, Apple introduced the CSS transition, which later became a
proprietary feature of Safari called CSS Animation.
 Representatives from Apple and Mozilla began adding the CSS
transitions module to the CSS Level 3 specification, closely
modeled on what Apple had already added to Webkit and moz.
Configuring the animations
Presented by Muhammad Ehtisham Siddiqui (BSCS)
18
 A CSS animation sequence can be created by styling the element with the
animation property.
 This property can be used to configure the timing, duration, and sequence of
the animation. @keyframes rule define the appearance of the animation.
 The keyframe is used to describe the rendering of the element in the animation
sequence.
Property Description
@keyframes Is used for specifying the animation
animation Is a shorthand property representing all the animation
properties, except the animation-play-state property
animation-name Is used for specifying the name of the @keyframes
animation
animation-duration Is used for specifying the duration of an animation cycle in
seconds or milliseconds. Default value is 0
Configuring the animations
Presented by Muhammad Ehtisham Siddiqui (BSCS)
19
Property Description
animation-
timingfunction
Is used for describing the progress of animation over one
cycle of its duration. Default value is “ease
animation-delay Is used for specifying the start value of animation. Default
value is 0
animation-
iterationcount
Is used for specifying the number of times an animation is
played. Default value is 1
animation-
direction
Is used for specifying whether or not the animation should
play in reverse on alternate cycles. Default value is
“normal”
animation-play-
state
Is used for specifying the state of the animation, that is
whether it is running or paused. Default value is “running”
Example (Try it)
Presented by Muhammad Ehtisham Siddiqui (BSCS)
20
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"
/><style>
body {
display: flex;
justify-content: center;
}
.ball {
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #FF5722;
animation: bounce 0.5s;
animation-direction: alternate;
animation-iteration-count: infinite;
}
.ball:hover{background-color:#0C6;animation:running;animation-duration:0.5s;animation-delay:2s;
}@keyframes bounce { from { transform: translate3d(0, 0, 0); }
to { transform: translate3d(0, 200px, 0); }
}</style>
<title>Untitled Document</title></head><body>
<div class="ball"></div></body>
</html>
Example 1. (Try it)
Presented by Muhammad Ehtisham Siddiqui (BSCS)
21
CSS :
<style type="text/css"> #traveler { position: absolute; width: 20px; height: 240px; -webkit-animation-
name: travel; -webkit-animation-timing-function: linear; -webkit-animation-iteration-count: infinite; -
webkit-animation-direction: alternate; -webkit-animation-duration: 4.8s; animation-name: travel;
animation-timing-function: linear; animation-iteration-count: infinite; animation-direction: alternate;
animation-duration: 4.8s; } #bouncer { position: absolute; width: 20px; height: 20px; background:
red; border-radius: 10px; -webkit-animation-name: bounce; -webkit-animation-iteration-count:
infinite; -webkit-animation-duration: 4.2s; animation-name: bounce; animation-iteration-count:
infinite; animation-duration: 4.2s; } </style>
HTML:
<div id="stage">
<div id="traveler">
<div id="bouncer">
<!-- -->
</div>
</div>
</div>
Link: https://www.the-art-of-web.com/css/bouncing-ball-animation/
Using CSS on Mobile Devices
Presented by Muhammad Ehtisham Siddiqui (BSCS)
22
 There are different ways to provide Web pages for mobile devices.
 The user can make use of style sheet for the handheld devices (all mobile
browsers do not recognize it).
 IPhone’s Safari and Opera’s Mini browsers support a new feature of CSS3
called media queries.
 CODE:
<link rel=”stylesheet” href=”styles/mobile.css” media=”only screen and (max-
device-width: 480px)”/>
Using CSS on Mobile Devices
Presented by Muhammad Ehtisham Siddiqui (BSCS)
23
 The five ways to provide Web pages for mobile devices are as follows:
1. Define a style sheet for mobile devices
2. Include a link to a mobile version of the Web site
3. Use JavaScript to detect mobile devices and redirect
4. Use a server-side scripting language to detect and redirect
5. Use the WURFL to detect mobile devices
Questions?
Presented by Muhammad Ehtisham Siddiqui (BSCS)
24

Mais conteúdo relacionado

Semelhante a Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui

Task 1 technical file
Task 1   technical fileTask 1   technical file
Task 1 technical file
Nathan_West
 
Getting Started with Adobe After Effects.pdf
Getting Started with Adobe After Effects.pdfGetting Started with Adobe After Effects.pdf
Getting Started with Adobe After Effects.pdf
saintrubysupply
 
Digital graphics technology
Digital graphics technologyDigital graphics technology
Digital graphics technology
hadilasharif
 
Digital Imaging
Digital ImagingDigital Imaging
Digital Imaging
wang wangt
 
Technical glossary
Technical glossaryTechnical glossary
Technical glossary
halo4robo
 
file types lecture notes
file types lecture notesfile types lecture notes
file types lecture notes
Finlay Jackson
 
Digital graphics technology by fateha
Digital graphics technology by fatehaDigital graphics technology by fateha
Digital graphics technology by fateha
haverstockmedia
 

Semelhante a Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui (20)

Animation in the web
Animation in the webAnimation in the web
Animation in the web
 
Task 1 technical file
Task 1   technical fileTask 1   technical file
Task 1 technical file
 
Getting Started with Adobe After Effects.pdf
Getting Started with Adobe After Effects.pdfGetting Started with Adobe After Effects.pdf
Getting Started with Adobe After Effects.pdf
 
Inserting imagesin html
Inserting imagesin htmlInserting imagesin html
Inserting imagesin html
 
Buiding Next Generation Websites Session 8 by Muhammad Ehtisham Siddiqui
Buiding Next Generation Websites Session 8 by Muhammad Ehtisham SiddiquiBuiding Next Generation Websites Session 8 by Muhammad Ehtisham Siddiqui
Buiding Next Generation Websites Session 8 by Muhammad Ehtisham Siddiqui
 
Digital graphics technology
Digital graphics technologyDigital graphics technology
Digital graphics technology
 
Digital Imaging
Digital ImagingDigital Imaging
Digital Imaging
 
Better DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen WorldBetter DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen World
 
Technical glossary
Technical glossaryTechnical glossary
Technical glossary
 
Optimize Images for SEO WordCamp Sacramento
Optimize Images for SEO WordCamp SacramentoOptimize Images for SEO WordCamp Sacramento
Optimize Images for SEO WordCamp Sacramento
 
Mo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent Web
Mo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent WebMo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent Web
Mo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent Web
 
Adobe after effects creative cloud cc 2017
Adobe after effects creative cloud cc 2017Adobe after effects creative cloud cc 2017
Adobe after effects creative cloud cc 2017
 
file types lecture notes
file types lecture notesfile types lecture notes
file types lecture notes
 
Unit 13
Unit 13Unit 13
Unit 13
 
About graphics-on-web
About graphics-on-webAbout graphics-on-web
About graphics-on-web
 
Digital graphics technology by fateha
Digital graphics technology by fatehaDigital graphics technology by fateha
Digital graphics technology by fateha
 
Task 1
Task 1Task 1
Task 1
 
HTML Images
HTML Images HTML Images
HTML Images
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
 
File types pro forma power point
File types pro forma power pointFile types pro forma power point
File types pro forma power point
 

Mais de Muhammad Ehtisham Siddiqui

Mais de Muhammad Ehtisham Siddiqui (20)

C programming Tutorial Session 4
C programming Tutorial Session 4C programming Tutorial Session 4
C programming Tutorial Session 4
 
C programming Tutorial Session 4
C programming Tutorial Session 4C programming Tutorial Session 4
C programming Tutorial Session 4
 
C programming Tutorial Session 3
C programming Tutorial Session 3C programming Tutorial Session 3
C programming Tutorial Session 3
 
C programming Tutorial Session 2
C programming Tutorial Session 2C programming Tutorial Session 2
C programming Tutorial Session 2
 
C programming Tutorial Session 1
C programming Tutorial Session 1C programming Tutorial Session 1
C programming Tutorial Session 1
 
HTML5 Web storage
HTML5 Web storageHTML5 Web storage
HTML5 Web storage
 
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham SiddiquiJ Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
 
JavaScript Session 2
JavaScript Session 2JavaScript Session 2
JavaScript Session 2
 
JavaScript Session 3
JavaScript Session 3JavaScript Session 3
JavaScript Session 3
 
Javascript session 1
Javascript session 1Javascript session 1
Javascript session 1
 
Html audio video
Html audio videoHtml audio video
Html audio video
 
Html 5 geolocation api
Html 5 geolocation api Html 5 geolocation api
Html 5 geolocation api
 
Building Next Generation Websites Session 6 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 6 by Muhammad Ehtisham SiddiquiBuilding Next Generation Websites Session 6 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 6 by Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
Building Next Generation Websites by Muhammad Ehtisham SiddiquiBuilding Next Generation Websites by Muhammad Ehtisham Siddiqui
Building Next Generation Websites by Muhammad Ehtisham Siddiqui
 
Building Next Generation Websites Session6
Building Next Generation Websites Session6Building Next Generation Websites Session6
Building Next Generation Websites Session6
 
Building Next Generation Websites Session5
Building Next Generation Websites Session5Building Next Generation Websites Session5
Building Next Generation Websites Session5
 
Building Next Generation Websites Session4
Building Next Generation Websites Session4Building Next Generation Websites Session4
Building Next Generation Websites Session4
 
Session4
Session4Session4
Session4
 
Office session14
Office session14Office session14
Office session14
 
Office session13
Office session13Office session13
Office session13
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui

  • 1. DISPLAYING GRAPHICS AND CSS3 ANIMATIONS SESSION 7 Aptech Computer Education Presented by Muhammad Ehtisham Siddiqui (BSCS) 1
  • 2. Objectives  Explain graphic formatting in Web pages  Explain graphic insertion, sizing, and padding  Explain CSS3 Animation  Describe the use of CSS3 on mobile devices Presented by Muhammad Ehtisham Siddiqui (BSCS) 2
  • 3. Introduction of Graphics and Animations Presented by Muhammad Ehtisham Siddiqui (BSCS) 3  CSS3 has allowed the designers to style their Web pages graphically with ease.  HTML5 applications provide amazing experiences with the use of new CSS3 animations.  The introduction of mobile applications has allowed the users to expand their Web usage to mobile devices.  CSS3 has introduced new features specifically for mobile devices.
  • 4. Graphic Format Presented by Muhammad Ehtisham Siddiqui (BSCS) 4  There are many graphic formats available; the most commonly used are Joint Photographic Experts Group (JPEG), Graphics Interchange Format (GIF), and Portable Network Graphics (PNG).  Some graphic format are as follows. Format Description Color Depth It is defined by the number of distinct colors that are represented by a hardware or software. Color depth is defined by the number of bits per pixel (bpp) and it is also called as bit depth. Higher the color depth indicates higher range of colors used. Compression/fi le size Graphic files are large, so images are compressed using various techniques. Compression stores the original images in a reduced number of bytes using an algorithm. This image can be expanded back to the original size using a decompression algorithm. In some compression formats, images with less complexity results in smaller compressed file sizes.
  • 5. Types of Compression(File Size) Presented by Muhammad Ehtisham Siddiqui (BSCS) 5  The two types of image file compression algorithms used are as follows:  Lossless compression  In this algorithm, file size is reduced but preserves a copy of the original uncompressed image. Lossless compression avoids accumulating stages of re-compression when editing images.  Lossy compression  In this algorithm, a representation of the original uncompressed image is preserved. The image appears to be a copy of the original image but in actuality it is not a copy. Lossy compression achieves smaller file sizes when compared with lossless compression. Generally, lossy compression algorithms allow variable compression that comprises on image quality for file size.
  • 6. Graphical Formats Presented by Muhammad Ehtisham Siddiqui (BSCS) 6  Animation  Some graphic format consists of a series of frames that are played one after the other giving an impression of animation. Animated graphics are typically used on a Web page to attract visitor’s attention.  Transparency  It is very common on the Web to display an image on a Web page that appears directly against the background color of the page. The background color of the Web page shows through the transparent portion of the image. In a transparent image, one and only one color can be hidden. If the color chosen to make transparent is same as the background of the inserted image, then an irregularly shaped image appears to float on the page. Figure 7.2 shows a transparent image.
  • 7. Graphic Format for the Web Presented by Muhammad Ehtisham Siddiqui (BSCS) 7  For Web pages, use of JPEG and PNG graphics are recommended as it provides maximum compatibility with all the devices that might be accessing the Web page. For photos, use of JPEG graphic format and for screen-shots and drawings use of PNG graphic format is recommended. Both these formats compress the picture information to reduce the download time and increase the downloading speed.  JPEG  It uses a lossy compression which means that the image quality is lost in the process of compressing the image. It is recommended that for continuous tone pictures such as photos JPEG should be used. If the quality is reduced, then the loss is visible; JPEG is about half the size of PNG.  PNG  It uses lossless compression, which means there is no loss of any image detail. PNG was designed for transferring images on the Internet and not for professional- quality print graphics; therefore it does not support non-RGB color spaces such as CMYK. It supports high color and partial transparency using alpha channels.
  • 8. Graphic Format for the Web Presented by Muhammad Ehtisham Siddiqui (BSCS) 8  GIF  It uses a lossless compression which means that there is no loss in quality when the image is compressed. The uncompressed image stores its information in a linear fashion. Each line of pixels is read from left to right. An interlaced GIF file stores the lines of the image in a different order. Animated graphics are stored in gif format.
  • 9. Graphic Insertion Presented by Muhammad Ehtisham Siddiqui (BSCS) 9  The IMG element is an empty element, which allows the user to insert an image in a Web page.  It allows insertion of images and diagrams. The commonly used graphic formats that are supported are namely, GIF, JPEG, BITMAP (BMP), and PNG.  The <img> tag reserves a space for the image and does not insert the image in the HTML page. It creates a link between the image and the HTML page.  The common attributes of IMG elements are as follows. Attributes Description Src Specifies the path of an image that is to be displayed. Height Specifies the height of an image. Width Specifies the width of an image.
  • 10. Figure Tag <figure> Presented by Muhammad Ehtisham Siddiqui (BSCS) 10  HTML5 introduced a new <figure> tag.  The <figure> tag acts as a container containing the <img> tag.  In other words, it is not a replacement for <img> tag, but acts as a container into which the <img> tag is placed.  The <figure> tag specifies self-contained content, such as illustrations, diagrams, photos, code listings, and so on.  Code: <figure> <img src=”logo.gif” style=”float: left” width=”304” height=”228” /> </figure>
  • 11. Figure Caption tag <figcaption> Presented by Muhammad Ehtisham Siddiqui (BSCS) 11  The <figcaption> tag allows the user to add a caption to the image. The caption always appears along with the image even if the image floats in Web site layout.  Code: <figure> <img src=”flower1.jpg”> <img src=”flower2.jpg”> <img src=”flower3.jpg”> <figcaption>The different types of flowers</figcaption> </figure>
  • 12. CSS Image Sizing/ Padding Presented by Muhammad Ehtisham Siddiqui (BSCS) 12  SIZE  Size of an image is specified in pixels.  The height and width property sets the height and width of the image.  One can specify the width and the height will be resized or vice versa.  CODE: p.ex { height:100px; width:100px; }
  • 13. CSS Image Sizing/ Padding Presented by Muhammad Ehtisham Siddiqui (BSCS) 13  PADDING  The CSS padding property is used to specify the space between the element border and the element content.  It is used to separate them from the surrounding element.  The background color of the element affects the padding property.  Using separate properties such as top, right, bottom, and left, different padding values can be specified and the padding can be changed separately.  CODE  padding-top:10px;  padding-bottom:10px;  padding-right:15px;  padding-left:15px;  CODE  padding:25px 50px 75px 100px;
  • 14. Thumbnail Graphics Presented by Muhammad Ehtisham Siddiqui (BSCS) 14  The speed of loading a page of a Web site is reduced if high-resolution graphics are used.  High-resolution graphics are required to improve the effectiveness of the site and cannot be avoided.  Hence, to avoid this issue, thumbnails are used.  A thumbnail is a small image, or a part of a larger image.  Clicking the thumbnail image will link to the larger original image, which can be viewed and downloaded.  Even a hover effect can be given through CSS and JavaScript.
  • 15. Thumbnails Presented by Muhammad Ehtisham Siddiqui (BSCS) 15  Code <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> img { border: 1px solid #ddd; border-radius: 4px; padding: 5px; width: 150px; } img:hover { box-shadow: 0 0 2px 1px ; } </style> </head> <body> <h2>Thumbnail Image</h2> <p>Click on the image to enlarge it.</p> <a target="_blank" href="img_forest.jpg"> <img src="img_forest.jpg" alt="Forest" style="width:150px"> </a> </body> </html>
  • 16. Transition Support Presented by Muhammad Ehtisham Siddiqui (BSCS) 16
  • 17. CSS 3 Transitions Presented by Muhammad Ehtisham Siddiqui (BSCS) 17  Interactivity is one of the important aspects of animation.  Earlier, a combination of HTML, CSS, and JavaScript were used to animate objects on the Web.  In 2007, Apple introduced the CSS transition, which later became a proprietary feature of Safari called CSS Animation.  Representatives from Apple and Mozilla began adding the CSS transitions module to the CSS Level 3 specification, closely modeled on what Apple had already added to Webkit and moz.
  • 18. Configuring the animations Presented by Muhammad Ehtisham Siddiqui (BSCS) 18  A CSS animation sequence can be created by styling the element with the animation property.  This property can be used to configure the timing, duration, and sequence of the animation. @keyframes rule define the appearance of the animation.  The keyframe is used to describe the rendering of the element in the animation sequence. Property Description @keyframes Is used for specifying the animation animation Is a shorthand property representing all the animation properties, except the animation-play-state property animation-name Is used for specifying the name of the @keyframes animation animation-duration Is used for specifying the duration of an animation cycle in seconds or milliseconds. Default value is 0
  • 19. Configuring the animations Presented by Muhammad Ehtisham Siddiqui (BSCS) 19 Property Description animation- timingfunction Is used for describing the progress of animation over one cycle of its duration. Default value is “ease animation-delay Is used for specifying the start value of animation. Default value is 0 animation- iterationcount Is used for specifying the number of times an animation is played. Default value is 1 animation- direction Is used for specifying whether or not the animation should play in reverse on alternate cycles. Default value is “normal” animation-play- state Is used for specifying the state of the animation, that is whether it is running or paused. Default value is “running”
  • 20. Example (Try it) Presented by Muhammad Ehtisham Siddiqui (BSCS) 20 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style> body { display: flex; justify-content: center; } .ball { width: 100px; height: 100px; border-radius: 50%; background-color: #FF5722; animation: bounce 0.5s; animation-direction: alternate; animation-iteration-count: infinite; } .ball:hover{background-color:#0C6;animation:running;animation-duration:0.5s;animation-delay:2s; }@keyframes bounce { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(0, 200px, 0); } }</style> <title>Untitled Document</title></head><body> <div class="ball"></div></body> </html>
  • 21. Example 1. (Try it) Presented by Muhammad Ehtisham Siddiqui (BSCS) 21 CSS : <style type="text/css"> #traveler { position: absolute; width: 20px; height: 240px; -webkit-animation- name: travel; -webkit-animation-timing-function: linear; -webkit-animation-iteration-count: infinite; - webkit-animation-direction: alternate; -webkit-animation-duration: 4.8s; animation-name: travel; animation-timing-function: linear; animation-iteration-count: infinite; animation-direction: alternate; animation-duration: 4.8s; } #bouncer { position: absolute; width: 20px; height: 20px; background: red; border-radius: 10px; -webkit-animation-name: bounce; -webkit-animation-iteration-count: infinite; -webkit-animation-duration: 4.2s; animation-name: bounce; animation-iteration-count: infinite; animation-duration: 4.2s; } </style> HTML: <div id="stage"> <div id="traveler"> <div id="bouncer"> <!-- --> </div> </div> </div> Link: https://www.the-art-of-web.com/css/bouncing-ball-animation/
  • 22. Using CSS on Mobile Devices Presented by Muhammad Ehtisham Siddiqui (BSCS) 22  There are different ways to provide Web pages for mobile devices.  The user can make use of style sheet for the handheld devices (all mobile browsers do not recognize it).  IPhone’s Safari and Opera’s Mini browsers support a new feature of CSS3 called media queries.  CODE: <link rel=”stylesheet” href=”styles/mobile.css” media=”only screen and (max- device-width: 480px)”/>
  • 23. Using CSS on Mobile Devices Presented by Muhammad Ehtisham Siddiqui (BSCS) 23  The five ways to provide Web pages for mobile devices are as follows: 1. Define a style sheet for mobile devices 2. Include a link to a mobile version of the Web site 3. Use JavaScript to detect mobile devices and redirect 4. Use a server-side scripting language to detect and redirect 5. Use the WURFL to detect mobile devices
  • 24. Questions? Presented by Muhammad Ehtisham Siddiqui (BSCS) 24

Notas do Editor

  1. Presentation slide for courses, classes, lectures et al.
  2. Beginning course details and/or books/materials needed for a class/project.
  3. Beginning course details and/or books/materials needed for a class/project.
  4. Beginning course details and/or books/materials needed for a class/project.
  5. Beginning course details and/or books/materials needed for a class/project.
  6. Beginning course details and/or books/materials needed for a class/project.
  7. Beginning course details and/or books/materials needed for a class/project.
  8. Beginning course details and/or books/materials needed for a class/project.
  9. Beginning course details and/or books/materials needed for a class/project.
  10. Beginning course details and/or books/materials needed for a class/project.
  11. Beginning course details and/or books/materials needed for a class/project.
  12. Beginning course details and/or books/materials needed for a class/project.
  13. Beginning course details and/or books/materials needed for a class/project.
  14. Beginning course details and/or books/materials needed for a class/project.
  15. Beginning course details and/or books/materials needed for a class/project.
  16. Beginning course details and/or books/materials needed for a class/project.
  17. Beginning course details and/or books/materials needed for a class/project.
  18. Beginning course details and/or books/materials needed for a class/project.
  19. Beginning course details and/or books/materials needed for a class/project.
  20. Beginning course details and/or books/materials needed for a class/project.
  21. Beginning course details and/or books/materials needed for a class/project.
  22. Beginning course details and/or books/materials needed for a class/project.
  23. Beginning course details and/or books/materials needed for a class/project.
  24. Example graph/chart.