在HTML新增link可使css加入效果,在css中寫入語法,h1,p,可以使標題與段落,各自加上想要的效果,如文字變色,文字大小。
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS練習</title>
<link rel="stylesheet" href="css/style1.css">
</head>
<body>
<h1>我是標題</h1>
<p>我是段落</p>
</body>
</html>
CSS
h1{
color:red;
font-size:36px;
}
p{
color:blue;
font-size:50px;
}
選擇器{
屬性:設定值;
屬性:設定值;
}
附上選擇器程式碼與範例圖片
在p段落中,我加上了類別選擇器(class),可以去做命名的動作,這樣我可以分別把同是p段落的語法加上不同的改變效果。
Html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS練習</title>
<link rel="stylesheet" href="css/style1.css">
</head>
<body>
<h1>我是標題</h1>
<p class="style1">我是段落</p>
<p class="style2">我是段落</p>
</body>
</html>
CSS
h1{
color: red;
font-size: 36px;
}
.style1{
color: sandybrown;
}
.style2{
color: seagreen;
}
當我要使連結在鼠標滑動過去時,有所變化的話,我們可以使用CSS的擬態選擇器。
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS練習</title>
<link rel="stylesheet" href="css/style1.css">
</head>
<body>
<h1>我是標題</h1>
<a href="#">我是連結</a>
</body>
</html>
CSS
h1{
color: red;
font-size: 36px;
}
a{
color: green;
font-size: 25px;
}
a:hover{
color: pink;
font-size: 30px;
}
a:active{
color:purple;
font-size: 40px;
}
以下設定是,鼠標滑過去,會放大字型與變成粉色,當我按下該連結時,會變成紫色與字型再次放大。
當我在網頁段落內容中的文字,想要去做排版的動作時,可以使用"line-height"這個語法,去做行高的設定。
常用排版語法有下列
以下只展現設定行高的設定。
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS練習</title>
<link rel="stylesheet" href="css/style1.css">
</head>
<body>
<h1>我是標題</h1>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptas itaque tenetur provident veritatis quo! Ducimus cupiditate distinctio animi veritatis ea! Repudiandae, aspernatur eveniet cumque quas corrupti assumenda expedita corporis. Vel perferendis earum totam debitis nihil, fuga recusandae quasi voluptates ab iste ratione nostrum odio consectetur doloribus alias eos sapiente nobis!</p>
</body>
</html>
CSS
h1{
color: red;
font-size: 36px;
}
p{
color: royalblue;
font-size: 20px;
line-height: 1.5;
}
有時候我們想要讓HTML的標籤中,加入線條時,我們可以這樣做,不只可以加在文字上,也可以加在圖片,或是其他HTML標籤上。
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS練習</title>
<link rel="stylesheet" href="css/style1.css">
</head>
<body>
<h1>我是標題</h1>
<img src="https://www.google.com.tw/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" >
</body>
</html>
CSS
h1{
color: blue;
font-size: 36px;
border: solid 5px red;
}
img{
border-top:solid 5px red ;
border-bottom: solid 5px orange;
border-left:solid 5px yellow;
border-right:solid 5px green ;
}
傅小羊
Sun, May 3, 2020 2:30 PM
HTML
CSS
前端
筆記
學習筆記