課程練習,說明如下
- CSS Reset:使用 CSS Tools: Reset CSS
- 使用 div 來進行排版:網頁水平置中
- header:一張圖片(img)
- body:
- 使用後代選擇器來進行設定
- p 段落:兩個段落,顏色為藍色,使用 Lorem 快速產生文字
- 留白:使用 padding (往內推)、margin (往外推)
- a 連結:修正為塊狀 (display:inline -> display:block) 且滑鼠滑過去後背景變成黑色
- footer:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>[CSS] CSS 基礎練習</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="page">
<div class="header"><img src="https://54725596729_d130df08f7_n.jpg" alt="Blog logo"></div>
<div class="body">
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quia nemo alias magnam perferendis saepe rem,
voluptatum quaerat neque similique vero obcaecati quas a vitae commodi laboriosam earum animi provident
nulla.</p>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quia nemo alias magnam perferendis saepe rem,
voluptatum quaerat neque similique vero obcaecati quas a vitae commodi laboriosam earum animi provident
nulla.</p>
<a href="https://jengting.blogspot.com/" target="_blank">~楓花雪岳~</a>
</div>
<div class="footer">地址:OO 市 XX 區 OO 路 XX 號</div>
</div>
</body>
</html>
style.cs
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
.page {
width: 800px;
margin-left: auto;
margin-right: auto;
}
.header {
border: 5px solid lightgray;
margin: auto;
padding: 10px;
;
}
.body {
border: 5px solid red;
margin: auto;
padding: 10px;
}
.body p {
color: blue;
margin-bottom: 30px;
}
.body a {
display: block;
text-align: center;
background: blue;
color: white;
width:100px;
padding: 10px;
margin-bottom: 50px;
}
.body a:hover {
background: black;
}
.footer {
background-color: lightpink;
text-align: center;
margin: auto;
padding: 10px;
}
結果