SlideShare a Scribd company logo
JavaScript and CSS
style
 Style css :
document.getElementById("id").style.property="value";
 Style object property categories:
 Background
 Border and Margin
 Layout
 List
 Positioning
 Table
 Text
Examples
div1 = document.getElementById("content");
div1.style.width = "800px";
div1.style.padding = "10px 20px 0px";
div.style.backgroundColor ="#ccf";
div.style.fontSize =“2.5em”;
JavaScript et css
<style type="text/css">
#img1 {
width: 200px;
}
</style>
…
<script type="text/javascript">
window.onload=function() {
var img=document.getElementById("img1");
var w=img.style.width;
…
}
</script>
JavaScript:
img.style.width="500px";
javascript
* fontSize: augmenter la taille de 0.2em
div1.style.fontSize=(parseFloat(div.style.fontSize)+0.2)+"em";
* Width : diminuer la taille de 50px
div1.style.width = (parseInt(div1.style.width)-50)+"px";
div1.style.width +=50;
* Decaler l’image 30px de la gauche
var img=document.getElementById("img1");
var pos=parseInt(img.style.left);
img.style.left= (pos+30)+"px";
parseFloat() parseInt()
Examples
http://ycchen.im.ncnu.edu.tw/www2011/lab/opacityJS.html
img1.style.opacity=1.0;
img2.style.opacity=0.0;
…
function imgShow() {
o1 = parseFloat(img1.style.opacity);
o2 = parseFloat(img2.style.opacity);
o1 -= 0.02;
o2 += 0.02;
img1.style.opacity=o1;
img2.style.opacity = o2;
if (o1>0)
window.setTimeout("imgShow()", 200);
}
CSSvs javascript
CSS屬性名稱 style.property (JavaScript )
width width
font-size fontSize
border-top borderTop
padding-left paddingLeft
float cssFloat
EXERCICE :
1) Inserer une image (largeur et hauteur 200px), créer un boutton lors du click on
modifier les dimensions de l’image (largeur a 300 px hauteur a 400px)
2) Ecriver un paragraphe et modifier ca taille a 18px
Background
Property Description
background Sets all background properties in one
backgroundAttachm
ent
Sets whether a background-image is fixed or scrolls
with the page
backgroundColor Sets the background-color of an element
backgroundImage Sets the background-image of an element
backgroundRepeat Sets if/how a background-image will be repeated
EXERCICE :
1) Créer un formulaire contenant l’input color et un boutton, choisir une
couleur et cliquer sur le boutton pour changer l’arriere plan
2) Créer un boutton pour mettre une image en arriere plan
Text
Property Description
color Sets the color of the text
font Sets all font properties in one
fontFamily Sets the font of an element
fontSize Sets the font-size of an element
fontStyle Sets the font-style of an element
fontVariant Displays text in a small-caps font
fontWeight Sets the boldness of the font
letterSpacing Sets the space between characters
lineHeight Sets the distance between lines
textAlign Aligns the text
textDecoration Sets the decoration of a text
textIndent Indents the first line of text
textTransform Sets capitalization effect on a text
whiteSpace Sets how to handle line-breaks and white-space in a text
wordSpacing Sets the space between words in a text
Text
Property Description
color Sets the color of the text
font Sets all font properties in one
fontFamily Sets the font of an element
fontSize Sets the font-size of an element
fontStyle Sets the font-style of an element
fontVariant Displays text in a small-caps font
fontWeight Sets the boldness of the font
letterSpacing Sets the space between characters
lineHeight Sets the distance between lines
textAlign Aligns the text
textDecoration Sets the decoration of a text
textIndent Indents the first line of text
textTransform Sets capitalization effect on a text
whiteSpace Sets how to handle line-breaks and white-space in a text
wordSpacing Sets the space between words in a text
EXERCICE :
1) Créer un paragraphe, itiiallement ca taille est de 12px, créer un boutton
qui en cliquant dessus modifie le texte du paragraphe comme suit:
(couleur en bleu, ca police « verdanna », ca taille 30px, italique, en
gras, aligner a gauche)
Border and Margin
border borderTop borderRight borderBottom borderLeft
borderColor borderTopColor borderRightColor borderBottomColor borderLeftColor
borderStyle borderTopStyle borderRightStyle borderBottomStyle borderLeftStyle
borderWidth borderTopWidth borderRightWidth borderBottomWidth borderLeftWidth
margin marginTop marginRight marginBottom marginLeft
padding paddingTop paddingRight paddingBottom paddingLeft
EXERCICE :
1) Créer deux blocs, initialement les deux aligner a gauche et de taille
100px (largeur et hauteur), ajouter un boutton, lors du clique aligner un
bloc a gauche et un bloc a droite, agrandir leurs taille de votre choix et
modifier leurs bordure (couleur, style et epaisseur)
2) Mettez du texte dans les blocs, et modifier les marges internes et
externes
Layout
Property Description
clear Sets on which sides of an element other floating elements are not
allowed
clip Sets the shape of an element
cssFloat Sets where an image or a text will appear (float) in another element
cursor Sets the type of cursor to be displayed
direction Sets the text direction of an element
display Sets how an element will be displayed
height Sets the height of an element
maxHeight Sets the maximum height of an element
maxWidth Sets the maximum width of an element
minHeight Sets the minimum height of an element
minWidth Sets the minimum width of an element
overflow Specifies what to do with content that does not fit in an element box
verticalAli
gn
Sets the vertical alignment of content in an element
visibility Sets whether or not an element should be visible
width Sets the width of an element
Layout
Property Description
clear Sets on which sides of an element other floating elements are not allowed
clip Sets the shape of an element
cssFloat Sets where an image or a text will appear (float) in another element
cursor Sets the type of cursor to be displayed
direction Sets the text direction of an element
display Sets how an element will be displayed
height Sets the height of an element
maxHeight Sets the maximum height of an element
maxWidth Sets the maximum width of an element
minHeight Sets the minimum height of an element
minWidth Sets the minimum width of an element
overflow Specifies what to do with content that does not fit in an element box
verticalAlign Sets the vertical alignment of content in an element
visibility Sets whether or not an element should be visible
width Sets the width of an element
EXERCICE :
1) Utiliser les mêmes blocs de l’exercice précédant, et créer deux boutons pour le
premier bloc, un deux boutons pour le deuxième bloc, chaque bouton permet
de faire disparaitre et réapparaitre le bloc, (utiliser visibility et display) qu’est ce
que vous remarquer ?
List
Property Description
listStyle Sets all the properties for a list in one
listStyleImage Sets an image as the list-item marker
listStylePosition Positions the list-item marker
listStyleType Sets the list-item marker type
Positioning
Property Description
bottom Sets how far the bottom edge of an element is above/below the
bottom edge of the parent element
left Sets how far the left edge of an element is to the right/left of the left
edge of the parent element
position Places an element in a static, relative, absolute or fixed position
right Sets how far the right edge of an element is to the left/right of the
right edge of the parent element
top Sets how far the top edge of an element is above/below the top edge
of the parent element
zIndex Sets the stack order of an element
EXERCICE :
1) Créer un bloc initialement en haut a gauche, créer un boutton lier a une
fonction js, lors du clique deplacer le bloc en bas a droite
Add/Remove/Toggle a class
 Use element.className
document.getElementById("menu").className="";
document.getElementById("menu").className +=
" anotherClass";
 Use element.classList
document.getElementById("menu").classList.add("anotherClass");
document.getElementById("menu").classList.remove("vip");
document.getElementById("menu").classList.toggle("bg");
<div id="menu" class="vmenu vip bg" >…</div>
Ad

Recommended

Basic css
Basic css
Gopinath Ambothi
 
Lecture 5
Lecture 5
uccwebcourses
 
Les07
Les07
Sudharsan S
 
Oracle 10g Forms Lesson 7
Oracle 10g Forms Lesson 7
KAMA3
 
Web Layout
Web Layout
Shawn Calvert
 
web Technolotogies notes lke CSS443.pptx
web Technolotogies notes lke CSS443.pptx
ssuser46d915
 
05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation
Nguyen Tuan
 
Les06
Les06
Life Makers/ Jordan جمعية صناع الحياة /الأردن
 
Style With Kyle - Kyle Smith
Style With Kyle - Kyle Smith
wcfay
 
CSS
CSS
ARJUN
 
Css class-02
Css class-02
Md Ali Hossain
 
CSS Cascade Style Sheet
CSS Cascade Style Sheet
Adeel Rasheed
 
Css properties exercises
Css properties exercises
CHAN DARA
 
Html
Html
Sadeek Mohammed
 
CSS for basic learner
CSS for basic learner
Yoeung Vibol
 
Css jon duckett - flashcards
Css jon duckett - flashcards
Chirag Aggarwal
 
Intro to HTML and CSS basics
Intro to HTML and CSS basics
Eliran Eliassy
 
Art of css
Art of css
Raphael Wanjiku
 
gdg_workshop 4 on web development HTML & CSS
gdg_workshop 4 on web development HTML & CSS
SaniyaKhan484230
 
Displaying.pptx
Displaying.pptx
naresh414857
 
5. Web Technology CSS Advanced
5. Web Technology CSS Advanced
Jyoti Yadav
 
Css from scratch
Css from scratch
Ahmad Al-ammar
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
Cascading style sheet
Cascading style sheet
Michael Jhon
 
Css
Css
Er. Nawaraj Bhandari
 
Css Complete Notes
Css Complete Notes
EPAM Systems
 
Css
Css
Kavi Bharathi R
 
Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3
Gheyath M. Othman
 
652469898-TP-1-Realisation-d-Un-Cable-RJ45.pdf
652469898-TP-1-Realisation-d-Un-Cable-RJ45.pdf
YounesOuladSayad1
 
CHAPITRE3_Fondements_Big_Data_MR_YARN - converted (1).pdf
CHAPITRE3_Fondements_Big_Data_MR_YARN - converted (1).pdf
YounesOuladSayad1
 

More Related Content

Similar to javascript web developpement framework web (20)

Style With Kyle - Kyle Smith
Style With Kyle - Kyle Smith
wcfay
 
CSS
CSS
ARJUN
 
Css class-02
Css class-02
Md Ali Hossain
 
CSS Cascade Style Sheet
CSS Cascade Style Sheet
Adeel Rasheed
 
Css properties exercises
Css properties exercises
CHAN DARA
 
Html
Html
Sadeek Mohammed
 
CSS for basic learner
CSS for basic learner
Yoeung Vibol
 
Css jon duckett - flashcards
Css jon duckett - flashcards
Chirag Aggarwal
 
Intro to HTML and CSS basics
Intro to HTML and CSS basics
Eliran Eliassy
 
Art of css
Art of css
Raphael Wanjiku
 
gdg_workshop 4 on web development HTML & CSS
gdg_workshop 4 on web development HTML & CSS
SaniyaKhan484230
 
Displaying.pptx
Displaying.pptx
naresh414857
 
5. Web Technology CSS Advanced
5. Web Technology CSS Advanced
Jyoti Yadav
 
Css from scratch
Css from scratch
Ahmad Al-ammar
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
Cascading style sheet
Cascading style sheet
Michael Jhon
 
Css
Css
Er. Nawaraj Bhandari
 
Css Complete Notes
Css Complete Notes
EPAM Systems
 
Css
Css
Kavi Bharathi R
 
Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3
Gheyath M. Othman
 
Style With Kyle - Kyle Smith
Style With Kyle - Kyle Smith
wcfay
 
CSS Cascade Style Sheet
CSS Cascade Style Sheet
Adeel Rasheed
 
Css properties exercises
Css properties exercises
CHAN DARA
 
CSS for basic learner
CSS for basic learner
Yoeung Vibol
 
Css jon duckett - flashcards
Css jon duckett - flashcards
Chirag Aggarwal
 
Intro to HTML and CSS basics
Intro to HTML and CSS basics
Eliran Eliassy
 
gdg_workshop 4 on web development HTML & CSS
gdg_workshop 4 on web development HTML & CSS
SaniyaKhan484230
 
5. Web Technology CSS Advanced
5. Web Technology CSS Advanced
Jyoti Yadav
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
Cascading style sheet
Cascading style sheet
Michael Jhon
 
Css Complete Notes
Css Complete Notes
EPAM Systems
 
Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3
Gheyath M. Othman
 

More from YounesOuladSayad1 (18)

652469898-TP-1-Realisation-d-Un-Cable-RJ45.pdf
652469898-TP-1-Realisation-d-Un-Cable-RJ45.pdf
YounesOuladSayad1
 
CHAPITRE3_Fondements_Big_Data_MR_YARN - converted (1).pdf
CHAPITRE3_Fondements_Big_Data_MR_YARN - converted (1).pdf
YounesOuladSayad1
 
Machine Learning Support Vector Machines.pdf
Machine Learning Support Vector Machines.pdf
YounesOuladSayad1
 
les systemes d'exploitation la gestion des entrés sorties
les systemes d'exploitation la gestion des entrés sorties
YounesOuladSayad1
 
CHAPITRE 1 systeme d'exploitation environnement
CHAPITRE 1 systeme d'exploitation environnement
YounesOuladSayad1
 
chapitre 0 systemes d'exploitation sommaire
chapitre 0 systemes d'exploitation sommaire
YounesOuladSayad1
 
initiation_a_access microsoft office access
initiation_a_access microsoft office access
YounesOuladSayad1
 
PJ - machine learning avec scikit-learn.pdf
PJ - machine learning avec scikit-learn.pdf
YounesOuladSayad1
 
developpement web HTML & CSS web Sémantique
developpement web HTML & CSS web Sémantique
YounesOuladSayad1
 
cours developpement web javascript 2023/2024
cours developpement web javascript 2023/2024
YounesOuladSayad1
 
cours web developpement statique AJAX 2024
cours web developpement statique AJAX 2024
YounesOuladSayad1
 
cours Cascading style sheet developpement web
cours Cascading style sheet developpement web
YounesOuladSayad1
 
Gestion de projet en l'Information_compressed.pdf
Gestion de projet en l'Information_compressed.pdf
YounesOuladSayad1
 
cours les formulaires 2 microsoft access
cours les formulaires 2 microsoft access
YounesOuladSayad1
 
cours TRI selection insertion bublle sort
cours TRI selection insertion bublle sort
YounesOuladSayad1
 
cours mysql machine learning SQL MYSQL 2024
cours mysql machine learning SQL MYSQL 2024
YounesOuladSayad1
 
developpement web framework cms developpement brute
developpement web framework cms developpement brute
YounesOuladSayad1
 
Programmation Web developpement dynamique
Programmation Web developpement dynamique
YounesOuladSayad1
 
652469898-TP-1-Realisation-d-Un-Cable-RJ45.pdf
652469898-TP-1-Realisation-d-Un-Cable-RJ45.pdf
YounesOuladSayad1
 
CHAPITRE3_Fondements_Big_Data_MR_YARN - converted (1).pdf
CHAPITRE3_Fondements_Big_Data_MR_YARN - converted (1).pdf
YounesOuladSayad1
 
Machine Learning Support Vector Machines.pdf
Machine Learning Support Vector Machines.pdf
YounesOuladSayad1
 
les systemes d'exploitation la gestion des entrés sorties
les systemes d'exploitation la gestion des entrés sorties
YounesOuladSayad1
 
CHAPITRE 1 systeme d'exploitation environnement
CHAPITRE 1 systeme d'exploitation environnement
YounesOuladSayad1
 
chapitre 0 systemes d'exploitation sommaire
chapitre 0 systemes d'exploitation sommaire
YounesOuladSayad1
 
initiation_a_access microsoft office access
initiation_a_access microsoft office access
YounesOuladSayad1
 
PJ - machine learning avec scikit-learn.pdf
PJ - machine learning avec scikit-learn.pdf
YounesOuladSayad1
 
developpement web HTML & CSS web Sémantique
developpement web HTML & CSS web Sémantique
YounesOuladSayad1
 
cours developpement web javascript 2023/2024
cours developpement web javascript 2023/2024
YounesOuladSayad1
 
cours web developpement statique AJAX 2024
cours web developpement statique AJAX 2024
YounesOuladSayad1
 
cours Cascading style sheet developpement web
cours Cascading style sheet developpement web
YounesOuladSayad1
 
Gestion de projet en l'Information_compressed.pdf
Gestion de projet en l'Information_compressed.pdf
YounesOuladSayad1
 
cours les formulaires 2 microsoft access
cours les formulaires 2 microsoft access
YounesOuladSayad1
 
cours TRI selection insertion bublle sort
cours TRI selection insertion bublle sort
YounesOuladSayad1
 
cours mysql machine learning SQL MYSQL 2024
cours mysql machine learning SQL MYSQL 2024
YounesOuladSayad1
 
developpement web framework cms developpement brute
developpement web framework cms developpement brute
YounesOuladSayad1
 
Programmation Web developpement dynamique
Programmation Web developpement dynamique
YounesOuladSayad1
 
Ad

Recently uploaded (20)

Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
ijab2
 
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
resming1
 
Cadastral Maps
Cadastral Maps
Google
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
Taqyea
 
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Yannis
 
4th International Conference on Computer Science and Information Technology (...
4th International Conference on Computer Science and Information Technology (...
ijait
 
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
samueljackson3773
 
Low Power SI Class E Power Amplifier and Rf Switch for Health Care
Low Power SI Class E Power Amplifier and Rf Switch for Health Care
ieijjournal
 
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
João Esperancinha
 
3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt
engaash9
 
OCS Group SG - HPHT Well Design and Operation - SN.pdf
OCS Group SG - HPHT Well Design and Operation - SN.pdf
Muanisa Waras
 
machine learning is a advance technology
machine learning is a advance technology
ynancy893
 
Engineering Mechanics Introduction and its Application
Engineering Mechanics Introduction and its Application
Sakthivel M
 
Great power lithium iron phosphate cells
Great power lithium iron phosphate cells
salmankhan835951
 
David Boutry - Mentors Junior Developers
David Boutry - Mentors Junior Developers
David Boutry
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
Fundamentals of Digital Design_Class_12th April.pptx
Fundamentals of Digital Design_Class_12th April.pptx
drdebarshi1993
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
ijab2
 
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
resming1
 
Cadastral Maps
Cadastral Maps
Google
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
Taqyea
 
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Yannis
 
4th International Conference on Computer Science and Information Technology (...
4th International Conference on Computer Science and Information Technology (...
ijait
 
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
samueljackson3773
 
Low Power SI Class E Power Amplifier and Rf Switch for Health Care
Low Power SI Class E Power Amplifier and Rf Switch for Health Care
ieijjournal
 
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
João Esperancinha
 
3. What is the principles of Teamwork_Module_V1.0.ppt
3. What is the principles of Teamwork_Module_V1.0.ppt
engaash9
 
OCS Group SG - HPHT Well Design and Operation - SN.pdf
OCS Group SG - HPHT Well Design and Operation - SN.pdf
Muanisa Waras
 
machine learning is a advance technology
machine learning is a advance technology
ynancy893
 
Engineering Mechanics Introduction and its Application
Engineering Mechanics Introduction and its Application
Sakthivel M
 
Great power lithium iron phosphate cells
Great power lithium iron phosphate cells
salmankhan835951
 
David Boutry - Mentors Junior Developers
David Boutry - Mentors Junior Developers
David Boutry
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
Fundamentals of Digital Design_Class_12th April.pptx
Fundamentals of Digital Design_Class_12th April.pptx
drdebarshi1993
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Ad

javascript web developpement framework web

  • 2. style  Style css : document.getElementById("id").style.property="value";  Style object property categories:  Background  Border and Margin  Layout  List  Positioning  Table  Text
  • 3. Examples div1 = document.getElementById("content"); div1.style.width = "800px"; div1.style.padding = "10px 20px 0px"; div.style.backgroundColor ="#ccf"; div.style.fontSize =“2.5em”;
  • 4. JavaScript et css <style type="text/css"> #img1 { width: 200px; } </style> … <script type="text/javascript"> window.onload=function() { var img=document.getElementById("img1"); var w=img.style.width; … } </script> JavaScript: img.style.width="500px";
  • 5. javascript * fontSize: augmenter la taille de 0.2em div1.style.fontSize=(parseFloat(div.style.fontSize)+0.2)+"em"; * Width : diminuer la taille de 50px div1.style.width = (parseInt(div1.style.width)-50)+"px"; div1.style.width +=50; * Decaler l’image 30px de la gauche var img=document.getElementById("img1"); var pos=parseInt(img.style.left); img.style.left= (pos+30)+"px"; parseFloat() parseInt()
  • 6. Examples http://ycchen.im.ncnu.edu.tw/www2011/lab/opacityJS.html img1.style.opacity=1.0; img2.style.opacity=0.0; … function imgShow() { o1 = parseFloat(img1.style.opacity); o2 = parseFloat(img2.style.opacity); o1 -= 0.02; o2 += 0.02; img1.style.opacity=o1; img2.style.opacity = o2; if (o1>0) window.setTimeout("imgShow()", 200); }
  • 7. CSSvs javascript CSS屬性名稱 style.property (JavaScript ) width width font-size fontSize border-top borderTop padding-left paddingLeft float cssFloat EXERCICE : 1) Inserer une image (largeur et hauteur 200px), créer un boutton lors du click on modifier les dimensions de l’image (largeur a 300 px hauteur a 400px) 2) Ecriver un paragraphe et modifier ca taille a 18px
  • 8. Background Property Description background Sets all background properties in one backgroundAttachm ent Sets whether a background-image is fixed or scrolls with the page backgroundColor Sets the background-color of an element backgroundImage Sets the background-image of an element backgroundRepeat Sets if/how a background-image will be repeated EXERCICE : 1) Créer un formulaire contenant l’input color et un boutton, choisir une couleur et cliquer sur le boutton pour changer l’arriere plan 2) Créer un boutton pour mettre une image en arriere plan
  • 9. Text Property Description color Sets the color of the text font Sets all font properties in one fontFamily Sets the font of an element fontSize Sets the font-size of an element fontStyle Sets the font-style of an element fontVariant Displays text in a small-caps font fontWeight Sets the boldness of the font letterSpacing Sets the space between characters lineHeight Sets the distance between lines textAlign Aligns the text textDecoration Sets the decoration of a text textIndent Indents the first line of text textTransform Sets capitalization effect on a text whiteSpace Sets how to handle line-breaks and white-space in a text wordSpacing Sets the space between words in a text
  • 10. Text Property Description color Sets the color of the text font Sets all font properties in one fontFamily Sets the font of an element fontSize Sets the font-size of an element fontStyle Sets the font-style of an element fontVariant Displays text in a small-caps font fontWeight Sets the boldness of the font letterSpacing Sets the space between characters lineHeight Sets the distance between lines textAlign Aligns the text textDecoration Sets the decoration of a text textIndent Indents the first line of text textTransform Sets capitalization effect on a text whiteSpace Sets how to handle line-breaks and white-space in a text wordSpacing Sets the space between words in a text EXERCICE : 1) Créer un paragraphe, itiiallement ca taille est de 12px, créer un boutton qui en cliquant dessus modifie le texte du paragraphe comme suit: (couleur en bleu, ca police « verdanna », ca taille 30px, italique, en gras, aligner a gauche)
  • 11. Border and Margin border borderTop borderRight borderBottom borderLeft borderColor borderTopColor borderRightColor borderBottomColor borderLeftColor borderStyle borderTopStyle borderRightStyle borderBottomStyle borderLeftStyle borderWidth borderTopWidth borderRightWidth borderBottomWidth borderLeftWidth margin marginTop marginRight marginBottom marginLeft padding paddingTop paddingRight paddingBottom paddingLeft EXERCICE : 1) Créer deux blocs, initialement les deux aligner a gauche et de taille 100px (largeur et hauteur), ajouter un boutton, lors du clique aligner un bloc a gauche et un bloc a droite, agrandir leurs taille de votre choix et modifier leurs bordure (couleur, style et epaisseur) 2) Mettez du texte dans les blocs, et modifier les marges internes et externes
  • 12. Layout Property Description clear Sets on which sides of an element other floating elements are not allowed clip Sets the shape of an element cssFloat Sets where an image or a text will appear (float) in another element cursor Sets the type of cursor to be displayed direction Sets the text direction of an element display Sets how an element will be displayed height Sets the height of an element maxHeight Sets the maximum height of an element maxWidth Sets the maximum width of an element minHeight Sets the minimum height of an element minWidth Sets the minimum width of an element overflow Specifies what to do with content that does not fit in an element box verticalAli gn Sets the vertical alignment of content in an element visibility Sets whether or not an element should be visible width Sets the width of an element
  • 13. Layout Property Description clear Sets on which sides of an element other floating elements are not allowed clip Sets the shape of an element cssFloat Sets where an image or a text will appear (float) in another element cursor Sets the type of cursor to be displayed direction Sets the text direction of an element display Sets how an element will be displayed height Sets the height of an element maxHeight Sets the maximum height of an element maxWidth Sets the maximum width of an element minHeight Sets the minimum height of an element minWidth Sets the minimum width of an element overflow Specifies what to do with content that does not fit in an element box verticalAlign Sets the vertical alignment of content in an element visibility Sets whether or not an element should be visible width Sets the width of an element EXERCICE : 1) Utiliser les mêmes blocs de l’exercice précédant, et créer deux boutons pour le premier bloc, un deux boutons pour le deuxième bloc, chaque bouton permet de faire disparaitre et réapparaitre le bloc, (utiliser visibility et display) qu’est ce que vous remarquer ?
  • 14. List Property Description listStyle Sets all the properties for a list in one listStyleImage Sets an image as the list-item marker listStylePosition Positions the list-item marker listStyleType Sets the list-item marker type
  • 15. Positioning Property Description bottom Sets how far the bottom edge of an element is above/below the bottom edge of the parent element left Sets how far the left edge of an element is to the right/left of the left edge of the parent element position Places an element in a static, relative, absolute or fixed position right Sets how far the right edge of an element is to the left/right of the right edge of the parent element top Sets how far the top edge of an element is above/below the top edge of the parent element zIndex Sets the stack order of an element EXERCICE : 1) Créer un bloc initialement en haut a gauche, créer un boutton lier a une fonction js, lors du clique deplacer le bloc en bas a droite
  • 16. Add/Remove/Toggle a class  Use element.className document.getElementById("menu").className=""; document.getElementById("menu").className += " anotherClass";  Use element.classList document.getElementById("menu").classList.add("anotherClass"); document.getElementById("menu").classList.remove("vip"); document.getElementById("menu").classList.toggle("bg"); <div id="menu" class="vmenu vip bg" >…</div>