Uploaded by Sahana Devi KJ

xhtml web manual

advertisement
Free Software Movement Karnataka
www.fsmk.org
Introduction to Web Programming (BPLCK105A/205A)
I/II Semester
(common to all branches)
LAB MANUAL
Prabodh C P
Asst Professor
Dept of CSE, SIT
Volunteer, FSMK
Visit : https://tinyurl.com/yc5h2mu9
The versioned repository of all the programs can be found here as a GitLab Repository
https://gitlab.com/lab_manuals/java_manual_vtu_2022_23
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
To veiw a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/4.0/
Contents
1 XHTML Page
1
2 XHTML Tables
4
3 HTML5
7
4 HTML5 Semantic Tags
9
5 Classes
12
6 li Tag
14
7 Signup Page
16
8 Calculator
19
9 Scroling Text
22
10 Overlapping Images
24
i
Listings
1.1 01Demo.html ................................................................................................................................................................ 1
2.1 02Table.html ................................................................................................................................................................ 4
3.1 03SvgMath.html .......................................................................................................................................................... 7
4.1 04semanticPage.html .................................................................................................................................................. 9
5.1 05classDemo.html ....................................................................................................................................................... 12
6.1 06changeTag.html ..................................................................................................................................................... 14
7.1 07Signup.html ............................................................................................................................................................ 16
08calcScreen.html ............................................................................................................................................................ 19
08calcstyle.css .................................................................................................................................................................. 20
9.1 09scrolling.html ......................................................................................................................................................... 22
10.1 10overlap.html............................................................................................................................................................ 24
ii
Preface
Usage of Free and Open Source Software
This manual has been prepared entirely using Free Software. The following Free Software has been used in preparation
of this manual.
Operating System Ubuntu 22.04.1 LTS (Jammy Jellyfish)
Linux Kernel 5.15.0-56-generic
Java Compiler javac 19.0.1
IDE Bluefish 2.2.12
Version Control git 2.34.1
Typesetting Texmaker 5.0.3 with LaTeX
Image Editing GIMP 2.10.30
I am sharing this manual under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
License. To veiw a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/4.0/.
You are free to share modify this manual with attribution for academic purposes. A repository of all the programs
can be found as GitLab repository in the following link https://gitlab.com/lab_manuals/web_22plc15a_
repo_vtu_2022_23. Looking for your feedback. If you want to contribute let me know by sending a PR on the
git repo mentioned earlier.
Use and spread the word of Free Software. Free Software leads to a Free Society!
Prabodh C P
iii
Chapter 1
XHTML Page
Question
Create an XHTML page using tags to accomplish the following:
1. A paragraph containing text “All that glitters is not gold”. Bold face and italicize this text
2. Create equation: x = 1/3(y21 + z21)
3. Put a background image to a page and demonstrate all attributes of background image
4. Create unordered list of 5 fruits and ordered list of 3 flowers
HTML Code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/
xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4 <head>
5 <title>SAMPLE XHTML PAGE</title>
6 <meta name="author" content="Putta" />
7 <meta name="date" content="2023-02-17T04:15:01+0530" />
8 <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
9 <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/>
10 <meta http-equiv="content-style-type" content="text/css"/>
11 <meta http-equiv="expires" content="0"/>
12 </head>
13 <body>
1
2
14
<style>
body {
17
background-image: url("image.png");
18
background-repeat: no-repeat;
19
background-position: right bottom;
20
background-attachment: fixed;
21 }
22 </style>
15
16
23
<h4>Paragraph</h4>
<p>
26 <b><i>All that glitters is not gold</i></b> is an aphorism stating that not
everything that looks precious or true turns out to be so.
27 While early expressions of the idea are known from at least the 12th-13th century,
the current saying is derived from a 16th-century line by William Shakespeare,
28 <b><i>All that glisters is not gold</i></b>.
29 <br /> <br />
30 <b><i>All that glisters is not gold</i></b><br />
24
25
1
CHAPTER 1. XHTML PAGE
Often have you heard that told.<br />
Many a man his life hath sold<br />
33 But my outside to behold.<br />
34 Gilded tombs do worms enfold.<br />
35 Had you been as wise as bold,<br />
36 Young in limbs, in judgment old,<br />
37 Your answer had not been inscrolled<br />
38 Fare you well. Your suit is cold<br />
31
32
39
40
41
-William Shakespeare, Merchant of Venice, Act II Scene 7
</p>
42
43
<h4>Equation</h4>
44
45
46
47
<i>x</i> = 1/3(<i>y</i><sub>1</sub><sup>2</sup> + <i>z</i><sub>1</sub><sup>2</sup>)
48
49
<h4>Unordered Fruit List</h4>
50
<ul>
<li>Banana</li>
53 <li>Mango</li>
54 <li>Grapes</li>
55 <li>Apples</li>
56 </ul>
51
52
57
<h4>Ordered Flower List</h4>
<ol>
60 <li>Jasmine</li>
61 <li>Rose</li>
62 <li>Lotus</li>
63 <li>Tulip</li>
64 </ol>
65 <br />
66 </body>
67 </html>
58
59
Listing 1.1: 01Demo.html
Dept of CSE, SIT - Prabodh C P
2
CHAPTER 1. XHTML PAGE
Output
=================================
Figure 1.1: Initial Page
Dept of CSE, SIT - Prabodh C P
3
Chapter 2
XHTML Tables
Question
Create following table using XHTML tags. Properly align cells, give suitable cell padding and cell
spacing, and apply background color, bold and emphasis necessary
HTML Code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/
xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4 <head>
5 <title>Table Demo XHTML PAGE</title>
6 <meta name="author" content="Putta" />
7 <meta name="date" content="2023-02-17T04:58:37+0530" />
8 <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
9 <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/>
10 <meta http-equiv="content-style-type" content="text/css"/>
11 <meta http-equiv="expires" content="0"/>
1
2
12
<style>
table, th, td {
15
border: 1px solid black;
16
border-collapse: collapse;
17 }
18 th, td{
19
padding-left: 10px;
20
padding-bottom: 20px
21 }
22 table {
23
border-spacing: 30px;
24 }
25 </style>
13
14
26
27
</head>
4
CHAPTER 2.
28
XHTML TABLES
<body>
29
30
<h3>Tables in XHTML</h3>
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<table align="center" width="70%" style="height:450px">
<tr >
<td rowspan="9" align="center" bgcolor=DEEEEE>
<b>Department</b>
</td>
<td rowspan="3" align="center" bgcolor=9E7BA0>
<b>Sem1</b>
</td>
<td padding:15px>
<em>SubjectA</em>
</td>
</tr>
<tr>
<td ><em>SubjectB</em></td>
</tr>
<tr>
<td ><em>SubjectC</em></td>
</tr>
50
51
52
53
54
55
56
57
58
59
60
61
62
<tr>
<td rowspan="3" align="center" bgcolor=9E7BA0>
<b>Sem2</b>
</td>
<td ><em>SubjectE</em></td>
</tr>
<tr>
<td ><em>SubjectF</em></td>
</tr>
<tr>
<td ><em>SubjectG</em></td>
</tr>
63
64
65
66
67
68
69
70
71
72
73
74
75
<tr>
<td rowspan="3" align="center" bgcolor=9E7BA0>
<b>Sem3</b>
</td>
<td ><em>SubjectH</em></td>
</tr>
<tr>
<td ><em>SubjectI</em></td>
</tr>
<tr>
<td ><em>SubjectJ</em></td>
</tr>
76
77
</table>
78
79
80
</body>
</html>
Listing 2.1: 02Table.html
Dept of CSE, SIT - Prabodh C P
5
CHAPTER 2.
XHTML TABLES
Output
=================================
Figure 2.1: Table Page
Dept of CSE, SIT - Prabodh C P
6
Chapter 3
HTML5
Question
Use HTML5 for performing following tasks:
1. Draw a square using HTML5 SVG , fill the square with green color and make 6px brown stroke width
2. Write the following mathematical expression by using HTML5 MathML: d = x2 − y2
3. Redirecting current page to another page after 5 seconds using HTML5 meta tag
HTML Code
<!DOCTYPE html>
<html>
3 <head>
4
<meta charset="utf-8" />
5
<title>HTML5 Demo</title>
6
<meta http-equiv="refresh" content="5; URL=http://www.vtu.ac.in">
7 </head>
8 <body>
9
<h3>HTML5 SVG</h3>
10
<svg width="200" height="200" align="centre">
11
<rect x="50" y="50" width="100" height="100" fill="green" stroke="brown"
stroke-width="6px"/>
12
</svg>
1
2
13
14
<h3>HTML5 MathML</h3>
15
16
17
18
19
20
21
22
23
24
<math xmlns = "http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mi>d</mi></msup>
<mo> = </mo>
<msup><mi>x</mi><mn>2</mn></msup>
<mo>-</mo>
<msup><mi>y</mi><mn>2</mn></msup>
</mrow>
</math>
25
26
27
28
<h3>This page redirects in 5 seconds</h3>
</body>
</html>
Listing 3.1: 03SvgMath.html
7
CHAPTER 3.
HTML5
Output
=================================
Figure 3.1: Initial Page
Figure 3.2: Redirected Page
Dept of CSE, SIT - Prabodh C P
8
Chapter 4
HTML5 Semantic Tags
Question
Demonstrate the following HTML5 Semantic tags- < article >, < aside >, < details >, < figcaption >, <
figure >, < footer >, < header >, < main >, < mark >, < section > for a webpage that gives information about
travel experience.
HTML Code
1
2
3
4
5
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>HTML5 Semantic Tags Demo</title>
6
<style>
body{
background-color: #FFFDD0;
}
aside {
float: right;
width: 25%;
background-color: cyan;
font-style: italic;
padding: 15px;
}
main {
float: left;
width: 70%;
}
footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
text-align: center;
}
mark {
background-color: yellow;
color: black;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
}
figure {
display: inline-block;
margin: auto;
33
34
35
36
}
37
38
figcaption {
9
CHAPTER 4. HTML5 SEMANTIC TAGS
font-style: italic;
39
40
41
}
</style>
42
</head>
<body>
45 <article>
46
<header>
47
<h1>My Travelogue</h1>
48
<p>Random Escapades</p>
49
</header>
43
44
50
51
<main>
<figure>
54
<img src="journey.jpeg" alt="Example Image" width="350" height="235">
55
<figcaption>The road never ends</figcaption>
56
</figure>
52
53
57
<section>
<h2>Ooty</h2>
60 <p>Ooty is a popular hill station located in the Nilgiri Hills. It is popularly
called the "Queen of Hill Stations".</p>
61 </section>
58
59
62
<section>
<h2>Mysore</h2>
65 <p> The city is also known as the City of Palaces, Mysuru has always enchanted its
visitors with its quaint charm.</p>
66 </section>
63
64
67
68
</main>
69
<aside>
<section>
72 <p>Upcoming Trek planned to <mark>Kumara Parvata</mark> will be sharing detils soon<
/p>
73 <details>
74
<summary>Tentative Dates</summary>
75
<p>24th January 2023</p>
76 </details>
77 </section>
78 </aside>
70
71
79
80
81
82
<footer>
<p>© 2023 Prabodh C P</p>
</footer>
83
</article>
</body>
86 </html>
84
85
Listing 4.1: 04semanticPage.html
Dept of CSE, SIT - Prabodh C P
10
CHAPTER 4. HTML5 SEMANTIC TAGS
Output
=================================
Figure 4.1: Initial Page
Figure 4.2: After clicking on Details
Dept of CSE, SIT - Prabodh C P
11
Chapter 5
Classes
Question
Create a class called income, and make it a background color of #0ff.
Create a class called expenses, and make it a background color of #f0f.
Create a class called profit, and make it a background color of #f00.
Throughout the document, any text that mentions income, expenses, or profit, attach the appropriate class to that piece of text. Further create following line of text in the same document:
The current price is 50| and new price is 40|
HTML Code
<!DOCTYPE html>
<html>
3 <head>
4 <meta charset="utf-8" />
5 <title>Class Selectors Demo</title>
6 <style>
7 .income {background-color: #0ff; font-style: italic;}
8 .expenses {background-color: #f0f;font-style: oblique;}
9 .profit {background-color: #ff0;font-weight: bold;}
10 .red{color: red;font-size: 24px;}
11 .strike{text-decoration: line-through; font-size: 24px;}
12 p {font-family: Cursive;}
13 </style>
14 </head>
15 <body>
16 <h1>Class Selectors Demo</h1>
17 <p>
18 Income, expenses, and profit are financial terms that are used to measure the
financial health of a person or a business.
19 </p>
20 <p class="income">
21 Income refers to the amount of money received by an individual or business from
various sources such as employment, investments, or sales of goods and services.
Income can be earned on a regular basis, such as a salary, or irregularly, such
as a bonus or one-time payment.
22 </p>
1
2
23
<p class="expenses">
Expenses, on the other hand, refer to the amount of money spent by an individual or
business to cover their costs of living or operating. Expenses can include fixed
costs such as rent or salaries, variable costs such as the cost of materials, or
discretionary costs such as entertainment or travel.
26 </p>
24
25
27
28
<p class="profit">
12
CHAPTER 5. CLASSES
Profit is the amount of money that remains after deducting expenses from income. It
represents the financial gain or loss that a person or business has generated
over a given period of time. A positive profit means that the income was greater
than the expenses, while a negative profit means that the expenses were greater
than the income.
30 </p>
29
31
32
<span class="strike">The current price is 50₹ </span><span class="red">and new
price is 40₹</span>
33
34
35
</body>
</html>
Listing 5.1: 05classDemo.html
Output
=================================
Dept of CSE, SKIT – Sahana Devi.k.J P
13
Chapter 6
li Tag
Question
Change the tag li to have the following properties:
• A display status of inline
• A medium, double-lined, black border
• No list style type
Add the following properties to the style for li:
• Margin of 5px
• Padding of 10px to the top, 20px to the right, 10px to the bottom, and 20px to the left
Also demonstrate list style type with user defined image logos
HTML Code
1
2
3
4
5
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Tag Properties </title>
6
<style>
.custom {
9
display: inline;
10
border: 2px double black;
11
list-style-type: none;
12
margin: 5px;
13
padding-top: 10px;
14
padding-right: 20px;
15
padding-bottom: 10px;
16
padding-left: 20px;
17
}
18
.logo {
19
list-style-image: url(’https://www.w3schools.com/cssref/sqpurple.gif’);
20
margin: 15px;
21
}
22
</style>
23 </head>
7
8
24
25
26
27
<body>
<h2>li Tag Property modification Demo</h2>
<h3>Current Top FootBall Players</h3>
28
14
Dept of CSE, SKIT – Sahana Devi.k.J P
CHAPTER 6. LI TAG
<ul>
<li class="custom">Lionel Messi</li>
31
<li class="custom">Kylian Mbappe</li>
32
<li class="custom">Lewandowski</li>
33
</ul>
34 <br>
35 <h2>list style type with user defined image logos</h2>
36 <h3>Current Top FootBall Goalkeepers</h3>
37
<ul class="logo">
38
<li>Emiliano Martinez</li>
39
<li>Thibaut Courtois</li>
40
<li>Yassine Bounou</li>
41
</ul>
29
30
42
43
44
45
</body>
</body>
</html>
Listing 6.1: 06changeTag.html
Output
=================================
Dept of CSE, SKIT – Sahana Devi.k.J P
15
Chapter 7
Signup Page
Question
Create following web page using HTML and CSS with tabular layout
Dept of CSE, SKIT – Sahana Devi.k.J P
HTML Code
1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
<head>
<title>Sign Up</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
10
11
12
13
14
15
16
.container {
width: 500px;
margin: 0 auto;
padding: 20px;
background-color: #F7E7CE;
border-radius: 5px;
16
CHAPTER 7. SIGNUP PAGE
box-shadow: 0 0 10px rgba(0,0,0,0.3);
17
}
18
19
table {
width: 100%;
}
20
21
22
23
th, td {
padding: 10px;
24
25
26
}
27
28
th {
29
text-align: left;
background-color: #f2f2f2;
30
31
}
32
33
input[type=text], input[type=password], input[type=email] {
width: 100%;
padding: 8px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
34
35
36
37
38
39
40
41
42
button[type=submit] {
background-color: #FFA500;
45
color: #fff;
46
padding: 10px 20px;
47
border: none;
48
border-radius: 4px;
49
cursor: pointer;
50
}
51
</style>
52 </head>
53 <body>
54
<div class="container">
55
<h1>Sign up Today</h1>
56
<form>
57
<table>
58
<tr>
59
<td><label for="username">Name:</label> <br>
60
<input type="text" id="username" name="username" required></td>
61
</tr>
43
44
62
<tr>
<td><label for="email">Email:</label> <br>
<input type="email" id="email" name="email" required></td>
</tr>
63
64
65
66
67
<tr>
<td><label for="password">Password:</label> <br>
<input type="password" id="password" name="password" required></
68
69
70
td>
</tr>
<tr>
<td><label for="password">Confirm password:</label> <br>
<input type="password" id="password" name="password" required></
71
72
73
74
td>
75
</tr>
76
CHAPTER 7. SIGNUP PAGE
Dept of CSE, SKIT – Sahana Devi.k.J P
17
77
78
79
80
81
82
83
84
<tr>
<td colspan="2"><button type="submit">Register</button></td>
</tr>
</table>
</form>
</div>
</body>
</html>
Listing 7.1: 07Signup.html
Output
=================================
Figure 7.1: Signup Page
Dept of CSE, SKIT – Sahana Devi.k.J P
18
Chapter 8
Calculator
Question
Create following calculator interface with HTML and CSS
HTML Code
<!DOCTYPE html>
<html>
3 <head>
4 <meta charset="utf-8" />
5 <title></title>
6 <link rel="stylesheet" type="text/css" href="calcstyle.css">
7 </head>
8 <body>
9 <div class="calculator">
10
<div class="display">
11
<p id="result">0</p>
12
</div>
13
<div class="buttons">
14
<button onclick="appendToDisplay(’(’)">(</button>
15
<button onclick="appendToDisplay(’)’)">)</button>
16
<button onclick="clearDisplay()">C</button>
17
<button onclick="appendToDisplay(’%’)">%</button>
18
<button onclick="appendToDisplay(’7’)">7</button>
1
2
19
CHAPTER 8.
<button
<button
21
<button
22
<button
23
<button
24
<button
25
<button
26
<button
27
<button
28
<button
29
<button
30
<button
31
<button
32
<button
33
<button
34
</div>
35 </div>
19
20
CALCULATOR
onclick="appendToDisplay(’8’)">8</button>
onclick="appendToDisplay(’9’)">9</button>
onclick="appendToDisplay(’*’)">X</button>
onclick="appendToDisplay(’4’)">4</button>
onclick="appendToDisplay(’5’)">5</button>
onclick="appendToDisplay(’6’)">6</button>
onclick="appendToDisplay(’-’)">-</button>
onclick="appendToDisplay(’1’)">1</button>
onclick="appendToDisplay(’2’)">2</button>
onclick="appendToDisplay(’3’)">3</button>
onclick="appendToDisplay(’+’)">+</button>
onclick="appendToDisplay(’0’)">0</button>
onclick="appendToDisplay(’.’)">.</button>
onclick="appendToDisplay(’/’)">/</button>
onclick="evaluate()">=</button>
36
37
38
</body>
</html>
Listing 8.1: 08calcScreen.html
CSS Code
.calculator {
display: flex;
3
flex-direction: column;
4
width: 350px;
5
margin: 10px;
6
border: 1px solid #ccc;
7
border-radius: 15px;
8
background-color: #F0C0FF;
9 }
1
2
10
11
.display {
12
background-color: #fff;
border-radius: 10px;
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3);
display: flex;
justify-content: flex-end;
align-items: center;
padding: 10px;
margin-left: 30px;
margin-right: 30px;
margin-top: 30px;
13
14
15
16
17
18
19
20
21
22
23
}
24
.buttons {
display: grid;
27
grid-template-columns: repeat(4, 1fr);
28
padding: 20px;
29 }
25
26
30
31
32
33
34
35
36
37
38
button {
padding: 20px;
background-color: #8D918D;
border: 1px solid #ccc;
border-radius: 10px;
cursor: pointer;
margin: 10px;
font-size: 18px;
Dept of CSE, SIT - Prabodh C P
20
CHAPTER 8.
font-weight: bold;
39
40
CALCULATOR
}
41
42
43
44
button:hover {
background-color: #d9d9d9;
}
45
46
47
48
button:active {
background-color: #bfbfbf;
}
49
#result {
margin: 0;
52
font-size: 24px;
53
font-weight: bold;
54 }
50
51
Listing 8.2: 08calcstyle.css
Output
=================================
Dept of CSE, SIT - Prabodh C P
21
Chapter 9
Scroling Text
Question
Write a Java Script program that on clicking a button, displays scrolling text which moves from
left to right with a small delay
HTML Code
<!DOCTYPE html>
<html>
3
<head>
4
<title>Scrolling Text Example</title>
5
<style>
6
#scrollingText {
7
font-size: 24px; font-weight: bold;
8
white-space: nowrap; overflow: hidden;
9
}
10
</style>
11
</head>
12
<body>
13
<button id="startBtn">Start Scrolling</button>
14
<div id="scrollingText">This is some scrolling text!</div>
15
<script>
16
var scrollingText = document.getElementById("scrollingText");
17
var startBtn = document.getElementById("startBtn");
18
var textWidth = scrollingText.clientWidth;
19
var containerWidth = scrollingText.parentNode.clientWidth;
20
var currentPosition = 0;
21
function scrollText() {
22
if (currentPosition < containerWidth) {
23
scrollingText.style.transform = "translateX(-" + currentPosition + "px)";
24
currentPosition += 1;
25
setTimeout(scrollText, 20);
26
} else {
27
currentPosition = -textWidth;
28
scrollText();
29
}
30
}
31
startBtn.addEventListener("click", function() {
32
currentPosition = 0;
33
scrollText();
34
});
35
</script>
36
</body>
37 </html>
1
2
Listing 9.1: 09scrolling.html
22
CHAPTER 9. SCROLING TEXT
Output
=================================
Figure 9.1: Initial Page
Figure 9.2: Page with Scrolled text
Dept of CSE, SIT - Prabodh C P
23
Chapter 10
Overlapping Images
Question
Create a webpage containing 3 overlapping images using HTML, CSS and JS. Further when the
mouse is over any image, it should be on the top and fully displayed.
HTML Code
<!DOCTYPE html>
<html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <meta name="author" content="Putta" >
6 <title>Animal Stacking</title>
7 <style>
8 h1 {text-align: center;}
1
2
9
.dog {
position: absolute;
12 left: 10%; top: 10%;
13 z-index: 0;
14 }
15 .cat {
16 position: absolute;
17 left: 30%; top: 30%;
18 z-index: 1;
19 }
20 .horse {
21 position: absolute;
22 left: 50%; top: 50%;
23 z-index: 2;
24 }
25 </style>
26 <script>
27 var topIndex = 2;
28 function moveToTop(picture) {
29 picture.style.zIndex = ++topIndex;
30 }
10
11
31
</script>
</head>
34
<body>
35
<h1>Image Overlap Demo</h1>
36
<div id="image-container">
37
<img id="dog" class="dog" src="dog.jpg" onmouseover="moveToTop(this)" width="
400" height="300">
32
33
24
CHAPTER 10. OVERLAPPING IMAGES
<img id="cat" class="cat" src="cat.jpg" onmouseover="moveToTop(this)" width="
400" height="300">
39
<img id="horse" class="horse" src="horse.jpg" onmouseover="moveToTop(this)"
width="400" height="300">
40
</div>
41
</body>
42 </html>
Listing 10.1: 10overlap.html
38
Output
=================================
(a) Mouse over Image 1
(b) Mouse over Image 2
(c) Mouse over Image 3
Dept of CSE, SIT - Prabodh C P
25
Download