html (source: https://www.pexels.com) |
Setelah sebelumnya saya membagikan script untuk membuat menu bar sederhana, kali ini saya ingin membagikan script untuk membuat sebuah layout website sederhana menggunakan HTML, CSS, dan JavaScript. Yang dimaksud layout di sini adalah tampilan website secara utuh dengan menu bar, konten, sidebar dsb. Langsung saja untuk scriptnya adalah sebagai berikut..
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Membuat Layout Sederhana</title>
<style type="text/css">
body{
background: linear-gradient(to right top, darkgrey, lightblue);
height: 1500px;
}
header ul{
position: fixed;
margin: 0;
top: 0;
left: 0;
background: rgb(100,150,225);
height: 40px;
width: 100%;
display: flex;
z-index: 1;
}
header li{
list-style-type: none;
float: left;
position: relative;
left: 10px;
width:120px;
text-align: center;
line-height: 40px;
font-family: verdana;
color: #fff;
}
header li:hover{
background: rgb(100,100,150);
height: 100%;
cursor: pointer;
}
.container{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
height: 1000px;
width: 700px;
background: transparent;
z-index: 0;
margin-top: 20%;
}
.header{
background: rgb(100,100,200);
height: 297px;
width: 100%;
}
.header h1{
margin-top: 0;
text-align: center;
line-height: 300px;
font-size: 40px;
font-family: verdana;
}
.isi{
display: flex;
position: relative;
bottom: 0;
top: 1%;
}
.konten{
background: #fff;
height: 700px;
width: 500px;
}
.konten p{
margin: 10px;
font-family: comic sans MS;
}
.sidebar{
background: rgb(150,150,210);
height: 700px;
width: 200px;
float: right;
border-top: 0;
cursor: pointer;
}
.sidebar li{
list-style-type: none;
position: relative;
top: 20px;
left: -20px;
background: lightgreen;
border: 1px solid purple;
line-height: 40px;
text-align: center;
color: #fff;
}
.footer{
background: rgb(100,100,100);
width: 100%;
height: 400px;
margin: 0;
left: 0;
position: absolute;
top: 200%;
}
.footer .copyright{
position: relative;
text-align: center;
top: 95%;
color: #fff;
}
</style>
</head>
<body>
<header>
<ul>
<li>Home</li>
<li>About</li>
<li>Privacy Policy</li>
<li>Contact Us</li>
</ul>
</header>
<div class="container">
<div class="header">
<h1>Hello World</h1>
</div>
<div class="isi">
<div class="konten">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<br>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="sidebar">
<ul>
<li>Otomotif</li>
<li>Elektronika</li>
<li>Informatika</li>
</ul>
</div>
</div>
</div>
<div class="footer">
<div class="copyright">copyright © Opp Code</div>
</div>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Membuat Layout Sederhana</title>
<style type="text/css">
body{
background: linear-gradient(to right top, darkgrey, lightblue);
height: 1500px;
}
header ul{
position: fixed;
margin: 0;
top: 0;
left: 0;
background: rgb(100,150,225);
height: 40px;
width: 100%;
display: flex;
z-index: 1;
}
header li{
list-style-type: none;
float: left;
position: relative;
left: 10px;
width:120px;
text-align: center;
line-height: 40px;
font-family: verdana;
color: #fff;
}
header li:hover{
background: rgb(100,100,150);
height: 100%;
cursor: pointer;
}
.container{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
height: 1000px;
width: 700px;
background: transparent;
z-index: 0;
margin-top: 20%;
}
.header{
background: rgb(100,100,200);
height: 297px;
width: 100%;
}
.header h1{
margin-top: 0;
text-align: center;
line-height: 300px;
font-size: 40px;
font-family: verdana;
}
.isi{
display: flex;
position: relative;
bottom: 0;
top: 1%;
}
.konten{
background: #fff;
height: 700px;
width: 500px;
}
.konten p{
margin: 10px;
font-family: comic sans MS;
}
.sidebar{
background: rgb(150,150,210);
height: 700px;
width: 200px;
float: right;
border-top: 0;
cursor: pointer;
}
.sidebar li{
list-style-type: none;
position: relative;
top: 20px;
left: -20px;
background: lightgreen;
border: 1px solid purple;
line-height: 40px;
text-align: center;
color: #fff;
}
.footer{
background: rgb(100,100,100);
width: 100%;
height: 400px;
margin: 0;
left: 0;
position: absolute;
top: 200%;
}
.footer .copyright{
position: relative;
text-align: center;
top: 95%;
color: #fff;
}
</style>
</head>
<body>
<header>
<ul>
<li>Home</li>
<li>About</li>
<li>Privacy Policy</li>
<li>Contact Us</li>
</ul>
</header>
<div class="container">
<div class="header">
<h1>Hello World</h1>
</div>
<div class="isi">
<div class="konten">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<br>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="sidebar">
<ul>
<li>Otomotif</li>
<li>Elektronika</li>
<li>Informatika</li>
</ul>
</div>
</div>
</div>
<div class="footer">
<div class="copyright">copyright © Opp Code</div>
</div>
</body>
</html>
Untuk hasilnya adalah sebagai berikut...
Sekian artikel dari saya, semoga bermanfaat:-)
0 Komentar