Professional Documents
Culture Documents
เฉลย-Lab10 - Ans
เฉลย-Lab10 - Ans
• เพื่อให้นิสิตเข้าใจภาษา CSS
• เพื่อให้นิสิตสามารถพัฒนาเว็บไซต์ด้วย CSS
แบบฝึกปฎิบัติการ
1. จงแสดงผลลัพธ์จากโค้ด HTML ต่อไปนี้โดยให้นสิ ิตคัดลอกหน้าจอผลลัพธ์ลงในช่องแสดงผลลัพธ์
โค้ดโปรแกรม
ผลลัพธ์
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
ผลลัพธ์
3. จากผลลัพธ์หน้าจอต่อไปนี้ให้นิสิตแปลงเป็นโค้ด HTML
ผลลัพธ์
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
โค้ดโปรแกรมสมบูรณ์
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Website Layout</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin: 0;
}
/* Style the header */
.header {
background-color: #e4bcbc;
padding: 20px;
text-align: center;
}
.sidenav {
height: 100%; /* Full-height: remove this if you want "auto" height */
width: 160px; /* Set the width of the sidebar */
position: fixed; /* Fixed Sidebar (stay in place on scroll) */
z-index: 1; /* Stay on top */
top: 8; /* Stay at the top */
left: 5;
background-color: #111; /* Black */
overflow-x: hidden; /* Disable horizontal scroll */
padding-top: 20px;
}
/* The navigation menu links */
.sidenav a {
padding: 6px 8px 6px 16px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
}
/* When you mouse over the navigation links, change their color */
.sidenav a:hover {
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
color: #f1f1f1;
}
</style>
</head>
<body>
<div class="header">
<h1>Header</h1>
</div>
<div class="sidenav">
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Clients</a>
<a href="#">Contact</a>
</div>
</body>
</html>
โค้ดโปรแกรมสมบูรณ์
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Website Layout</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
*{
box-sizing: border-box;
}
body {
margin: 0;
}
.sidenav {
height: 100%; /* Full-height: remove this if you want "auto" height */
width: 160px; /* Set the width of the sidebar */
position: fixed; /* Fixed Sidebar (stay in place on scroll) */
z-index: 1; /* Stay on top */
top: 0; /* Stay at the top */
left: 5;
background-color: #111; /* Black */
overflow-x: hidden; /* Disable horizontal scroll */
padding-top: 20px;
}
/* The navigation menu links */
.sidenav a {
padding: 6px 8px 6px 16px;
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
}
/* When you mouse over the navigation links, change their color */
.sidenav a:hover {
color: #f1f1f1;
}
</style>
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
</head>
<body>
<div class="header">
<h1>Header</h1>
</div>
<div class="sidenav">
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Clients</a>
<a href="#">Contact</a>
</div>
<div class="row">
<div class="column">
<h2>Column</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sit amet pretium
urna. Vivamus venenatis velit nec neque ultricies, eget elementum magna tristique.
Quisque vehicula, risus eget aliquam placerat, purus leo tincidunt eros, eget luctus quam
orci in velit. Praesent scelerisque tortor sed accumsan convallis.</p>
</div>
<div class="column">
<h2>Column</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sit amet pretium
urna. Vivamus venenatis velit nec neque ultricies, eget elementum magna tristique.
Quisque vehicula, risus eget aliquam placerat, purus leo tincidunt eros, eget luctus quam
orci in velit. Praesent scelerisque tortor sed accumsan convallis.</p>
</div>
<div class="column">
<h2>Column</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sit amet pretium
urna. Vivamus venenatis velit nec neque ultricies, eget elementum magna tristique.
Quisque vehicula, risus eget aliquam placerat, purus leo tincidunt eros, eget luctus quam
orci in velit. Praesent scelerisque tortor sed accumsan convallis.</p>
</div>
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
</div>
<div class="footer">
<p>Footer</p>
</div>
</body>
</html>
โค้ดโปรแกรมสมบูรณ์
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Website Layout</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
*{
box-sizing: border-box;
}
body {
margin: 0;
}
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
.sidenav {
height: 100%; /* Full-height: remove this if you want "auto" height */
width: 160px; /* Set the width of the sidebar */
position: fixed; /* Fixed Sidebar (stay in place on scroll) */
z-index: 1; /* Stay on top */
top: 0; /* Stay at the top */
left: 5;
background-color: #111; /* Black */
overflow-x: hidden; /* Disable horizontal scroll */
padding-top: 20px;
}
/* The navigation menu links */
.sidenav a {
padding: 6px 8px 6px 16px;
text-decoration: none;
font-size: 20px;
color: #818181;
display: block;
}
/* When you mouse over the navigation links, change their color */
.sidenav a:hover {
color: #f1f1f1;
}
padding: 15px;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other instead of
next to each other */
@media screen and (max-width:900px) {
.column {
width: 60%;
}
}
/* Table */
#customers {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#customers th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #04AA6D;
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
color: white;
}
</style>
</head>
<body>
<div class="header">
<h1>ระบบทะเบียนมหาวิทยาลัยบูรพา</h1>
</div>
<div class="sidenav">
<a href="#">เข้าสู่ระบบ</a>
<a href="#">วิชาที่เปิดสอน</a>
<a href="#">ตารางเรียนนิสิต</a>
<a href="#">ตารางการใช้ห้อง</a>
</div>
<div class="row">
<div class="column">
<h2>รายวิชาที่เรียน</h2>
<table id="customers">
<tr>
<th>ลาดับ</th>
<th>รหัสวิชา</th>
<th>หน่วยกิต</th>
</tr>
<tr>
<td>1</td>
<td>88612547</td>
<td>3</td>
</tr>
<tr>
<td>2</td>
<td>88635359</td>
<td>3</td>
</tr>
</table>
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
</div>
<div class="column">
<h2>ประกาศเรื่อง</h2>
<p>กาหนดการประเมินการเรียนการสอนปีการศึกษา 2565 ภาคปลาย</p>
</div>
</div>
</body>
</html>
Code
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Website Layout</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
*{
box-sizing: border-box;
}
body {
margin: 0;
}
p{
font-size: 20px;
font-style: italic;
}
/* Style the header */
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
.header {
background-color: rgb(255, 255, 255);
padding: 25px;
text-align: center;
border: 1px solid rgb(5, 5, 5);
}
.sidenav {
height: 100%; /* Full-height: remove this if you want "auto" height */
width: 180px; /* Set the width of the sidebar */
position: fixed; /* Fixed Sidebar (stay in place on scroll) */
z-index: 1; /* Stay on top */
top: 0; /* Stay at the top */
left: 5;
background-color: rgba(255, 255, 255, 0.849); /* Black */
overflow-x: hidden; /* Disable horizontal scroll */
padding-top: 20px;
border: 1px solid rgb(5, 5, 5);
}
/* The navigation menu links */
.sidenav a {
padding: 6px 8px 6px 16px;
text-decoration: none;
font-size: 20px;
color: #818181;
display: block;
}
/* When you mouse over the navigation links, change their color */
.sidenav a:hover {
color: #f1f1f1;
}
/* Create table*/
#customers {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
padding: 8px;
}
#customers th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #04AA6D;
color: white;
}
/*VDO display*/
video {
max-width: 100%;
height: auto;
}
/*Image */
img {
max-width: 80%;
height: auto;
}
/* Create three equal columns that floats next to each other */
.column {
float: right;
width: 29.80%;
padding: 15px;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other
instead of next to each other */
@media screen and (max-width:900px) {
.column {
width: 60%;
}
}
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
</style>
</head>
<body>
<div class="header">
<h1>Main Menu of Staff</h1>
</div>
<div class="sidenav">
<img src="logo.jpg" width="460" height="300">
<a href="#">จัดการข้อมูลผู้ใช้</a>
<a href="#">ข้อมูลสมาชิก</a>
<a href="#">ออกจากระบบ</a>
</div>
<div class="row">
<div class="column">
<h2>สินค้าขายดี</h2>
<table id="customers">
<tr>
<th>ลาดับ</th>
<th>ชื่อสินค้า</th>
<th>ยอดขายรวม (บาท)</th>
</tr>
<tr>
<td>1</td>
<td>Maria</td>
<td>5,600</td>
</tr>
<tr>
<td>2</td>
<td>Christina</td>
<td>5,600</td>
</tr>
<tr>
<td>3</td>
<td>Francisco</td>
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
<td>5,600</td>
</tr>
<tr>
<td>4</td>
<td>Roland</td>
<td>5,600</td>
</tr>
</table>
</div>
<div class="column">
<h2>สินค้าขายไม่ดี</h2>
<table id="customers">
<tr>
<th>ลาดับ</th>
<th>ชื่อสินค้า</th>
<th>ยอดขายรวม (บาท)</th>
</tr>
<tr>
<td>1</td>
<td>Yoshi</td>
<td>0.0</td>
</tr>
<tr>
<td>2</td>
<td>Giovanni</td>
<td>0.0</td>
</tr>
<tr>
<td>3</td>
<td>Simonr</td>
<td>0.0</td>
</tr>
<tr>
<td>4</td>
<td>Marie</td>
<td>0.0</td>
</tr>
</table>
</div>
<div class="column">
User Interface Design and Development ปฏิบตั ิการที่ 10 CSS EP2
<h2>VDO แนะนา</h2>
<video width="400" controls>
<source src="mov_bbb.mp4" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML5 video.
</video>
</div>
</div>
<div class="footer">
<p>D-coffee</p>
</div>
</body>
</html>