In: Computer Science
Here is the HTML code for UI. The UI is made with an assumption of hospital's website
<!DOCTYPE html>
<html>
<head>
<title>Home work</title>
<script src="theme_changer.js"></script>
<link rel="stylesheet" type="text/css" href="theme 1.css" id="theme">
</head>
<body>
<header>XYZ Clinic</header>
<nav><a href="#">Home</a> | <a href="#">Contact Us</a> | <a href="#" onclick="change_theme()">Change Theme</a></nav>
<section id="main_section">
<aside>
we are delivering the quality services in the filed of hospitality and helth care.
</aside>
<article id="first_article">
<figure>
<h1>Cardiologist</h1>
<img src="image1.jpg" style="width:30%">
<figcaption>Dr. John</figcaption>
</figure>
</article>
<article id="second_article">
<figure>
<h1>Neurologist</h1>
<img src="image2.jpg" style="width:30%">
<figcaption>Dr. Alberto</figcaption>
</figure>
</article>
<article id="third_article">
<figure>
<h1>Dentist</h1>
<img src="image3.jpg" style="width:30%">
<figcaption>Dr. Marita</figcaption>
</figure>
</article>
<footer>Thank you</footer>
</section>
</body>
</html>
Explaination:
as mantioned we have putted
along with external stylesheet and javascript.
Here is the them 1.css
header{
text-align: center;
background-color: #ccbbff;
}
nav > a{
text-decoration: none;
color: white;
}
nav{
background-color: #981267;
color: white;
}
aside {
width: 30%;
float: right;
background-color: yellow;
font-style: italic;
margin-left: 15px;
padding-left: 15px;
}
#first_article{
background-color: #982134;
}
#second_article{
background-color: #986734;
}
#third_article{
background-color: #981267;
}
figure{
align-content: center;
}
section{
background-color: #345677;
}
footer{
text-align: center;
}
and the code for theme 2.css
header{
text-align: center;
background-color: #ccbbff;
}
nav > a{
text-decoration: none;
color: white;
}
nav{
background-color: #981267;
color: white;
}
aside {
width: 30%;
float: right;
background-color: yellow;
font-style: italic;
margin-left: 15px;
padding-left: 15px;
}
#first_article{
background-color: #986734;
}
#second_article{
background-color: #981267;
}
#third_article{
background-color: #982134;
}
figure{
align-content: center;
}
section{
background-color: #345677;
}
footer{
text-align: center;
}
and here is the final functional code for changing them using Javascript theme_changer.js with explanation in with it.
//Fisr we have Define a function which will handle my themes
//Lets consider it change_theme()
function change_theme() {
//Now we have to find the link element in wich we have define our style sheet.
element = document.getElementById("theme");
//After that we have to check that which theme or style sheet our web page is using for that we will use the Ternary operator
//If our web page is using theme 1 then the variable elemet.p will be theme 2
//If web page is using theme 2 the the variable elemet.p will carry the value theme 1
element.p = 'theme 2' == element.p ? 'theme 1' : 'theme 2';
// After that we have to set alternate style sheet to our web page
// For that we will use the value stored in elemet.p and append .css in it
// and finaly assign the value to href atribute of link elemet.
element.href = element.p + '.css';
}