DESAIN WEB (LAYOUT CSS)
LAYOUT CSS
- Position Static
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
div {
padding: 10px;
}
.green {
background-color: green;
position: static;
}
.red {
background-color: red;
position: static;
}
.yellow {
background-color: yellow;
position: static;
}
</style>
</head>
<body>
<div class="green">Green</div>
<div class="red">Red</div>
<div class="yellow">Yellow</div>
</body>
</html>
HASIL :
3. Position Absolute
.red {
background-color: red;
position: absolute;
top: 10px;
}
4. Position Fixed
.container {
height: 1200px;
border: 1px solid #000000;
}
div {
padding: 10px;
}
.green {
background-color: green;
position: static;
}
.red {
background-color: red;
position: fixed;
top: 0px;
}
.yellow {
background-color: yellow;
position: static;
}
</style>
</head>
<body>
<div class="container">
<div class="green">Green</div>
<div class="red">Red</div>
<div class="yellow">Yellow</div>
</div>
HASIL :
5. Floats
<img
src="img/laura-jones.jpg"
alt="Headshot of Laura Jones"
height="50"
width="50"
class="author-img"
/>
<p id="author" class="author">
Posted by <strong>Laura Jones</strong> on Monday, June 21st 2027
</p>
/* FLOATS */
.author-img {
float: left;
margin-bottom: 20px;
}
.author {
float: left;
margin-top: 10px;
margin-left: 20px;
}
h1 {
float: left;
}
nav {
float: right;
}
.clear {
clear: both;
}
6. Clearing Floats
<nav>
<!-- <strong>This is the navigation</strong> -->
<a href="blog.html">Blog</a>
<a href="#">Challenges</a>
<a href="#">Flexbox</a>
<a href="#">CSS Grid</a>
</nav>
<div class="clear"></div>
</header>
/* FLOATS */
.author-img {
float: left;
margin-bottom: 0px;
}
.author {
float: left;
margin-top: 0px;
margin-left: 70px;
}
h1 {
float: left;
}
nav {
float: right;
}
.clear {
clear: both;
}
7. Box Sizing
aside {
background-color: #f7f7f7;
border-top: 5px solid #1098ad;
border-bottom: 5px solid #1098ad;
/* padding-top: 50px;
padding-bottom: 50px; */
padding: 50px 0;
width: 500px;
}
8.Flexbox
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Flexbox</title>
<style>
.el--1 {
background-color: blueviolet;
}
.el--2 {
background-color: orangered;
}
.el--3 {
background-color: green;
height: 150px;
}
.el--4 {
background-color: goldenrod;
}
.el--5 {
background-color: palevioletred;
}
.el--6 {
background-color: steelblue;
}
.el--7 {
background-color: yellow;
}
.el--8 {
background-color: crimson;
}
.container {
/* STARTER */
font-family: sans-serif;
background-color: #ddd;
font-size: 40px;
margin: 40px;
/* FLEXBOX */
}
</style>
</head>
<body>
<div class="container">
<div class="el el--1">HTML</div>
<div class="el el--2">and</div>
<div class="el el--3">CSS</div>
<div class="el el--4">are</div>
<div class="el el--5">amazing</div>
<div class="el el--6">languages</div>
<div class="el el--7">to</div>
<div class="el el--8">learn</div>
</div>
</body>
</html>




Komentar
Posting Komentar