CSS 是什么?
CSS是Cascading Style Sheets的簡稱,中文稱為層疊樣式表。
屬性和屬性值用冒號隔開,以分號結尾。
CSS 四種引入方式:
1.行內式
行內式是在標簽的style屬性中設定CSS樣式。
<div style="..."></div>
2.嵌入式
嵌入式是將CSS樣式集中寫在網頁的<head>標簽的<style></style>標簽對中。
<head>
...
<style type="text/css">
...此處寫CSS樣式
</style>
</head>
3.導入式
將一個獨立的.css文件引入HTML文件中,導入式使用@import 引入外部CSS文件,<style>標記也是寫在<head>標記中。
導入式會在整個網頁裝載完后再裝載CSS文件。
<head>
...
<style type="text/css">
@import "My.css"; 此處注意.css文件的路徑
</style>
</head>
4.鏈接式
將一個獨立的.css文件引入到HTML文件中,使用<link>標記寫在<head>標記中。
鏈接式會以網頁文件主體裝載前裝載CSS文件。
<head>
...
<link href="My.css" rel="stylesheet" type="text/css">
</head>
樣式應用順序:
.nick {
color: yellow !important;
}
基本選擇器:
1.通用元素選擇器
* 表示應用到所有的標簽。
* {color: yellow}
2.標簽選擇器
匹配所有使用 div 標簽的元素(可以匹配所有標簽)
div {color: yellow}
3.類選擇器
匹配所有class屬性中包含info的元素。
語法:.類名{樣式}(類名不能以數字開頭,類名要區分大小寫。)
.Mycolor {color: yellow}
<h3 class="Mycolor">nick</h3>
4.ID選擇器
使用id屬性來調用樣式,在一個網頁中id的值都是唯一的(是W3C規范而不是規則,所以不會報錯)。
語法:#ID名{樣式}(ID名不能以數字開頭)
#Mycolor {color: yellow}
<h3 id="Mycolor">Nick.</h3>
組合選擇器:
1.多元素選擇器
同時匹配h3,h4標簽,之間用逗號分隔。
h3,h4 {color: yellow;}
<h3>Nick</h3>
<h4>Jenny</h4>
2.后代元素選擇器
匹配所有div標簽里嵌套的P標簽,之間用空格分隔。
div p {color: yellow;}
<div>
<p>Nick</p>
<div>
<p>Nick</p>
</div>
</div>
3.子元素選擇器
匹配所有div標簽里嵌套的子P標簽,之間用>分隔。
div > p {color: yellow;}
<div>
<p>Nick</p>
<p>Nick</p>
</div>
4.毗鄰元素選擇器
匹配所有緊隨div標簽之后的同級標簽P,之間用+分隔(只能匹配一個)。
div + p {color: yellow;}
<div>Nick</div>
<p>Nick</p>
屬性選擇器:
1.[title] & P[title]
設置所有具有title屬性的標簽元素;
設置所有具有title屬性的P標簽元素。
[title]
{
color: yellow;
}
p[title]
{
color: yellow;
}
<div title>Nick</div>
<p title>Nick</p>
2.[title=Nick]
設置所有title屬性等于“Nick”的標簽元素。
[title="Nick"]
{
color: yellow;
}
<p title="Nick">Nick</p>
3.[title~=Nick]
設置所有title屬性具有多個空格分隔的值、其中一個值等于“Nick”的標簽元素。
[title~="Nick"]
{
color: yellow;
}
<p title="Nick Jenny">Nick</p>
<p title="Jenny Nick">Nick</p>
4.[title|=Nick]
設置所有title屬性具有多個連字號分隔(hyphen-separated)的值、其中一個值以"Nick"開頭的標簽元素。
例:lang屬性:"en"、"en-us"、"en-gb"等等
[title|="Nick"]
{
color: yellow;
}
<p title="Nick-Jenny">Nick</p>
5.[title^=Nick]
設置屬性值以指定值開頭的每個標簽元素。
[title^="Nick"]
{
color: yellow;
}
<p title="NickJenny">Nick</p>
6.[title$=Nick]
設置屬性值以指定值結尾的每個標簽元素。
[title$="Nick"]
{
color: yellow;
}
<p title="JennyNick">Nick</p>
7.[title*=Nick]
設置屬性值中包含指定值的每個元素
[title*="Nick"]
{
color: yellow;
}
<p title="SNickJenny">Nick</p>
偽類選擇器:
1. link、hover、active、visited
a:link{color: black}
a:hover{color: yellow}
a:active{color: blue}
a:visited{color: red}
<a href="#">Nick</a>
2. before、after
p {
color: yellow;
}
p:before{
content: "before...";
}
p:after{
content: "after...";
}
<p> Nick </p>
1. 顏色屬性:
color
transparent
opacity
2. 字體屬性:
font-style: 用于規定斜體文本
font-weight: 設置文本的粗細
font-size: 設置字體的大小
font-family:字體名稱
font:簡寫屬性
3. 文本屬性:
white-space: 設置元素中空白的處理方式
direction: 規定文本的方向
text-align: 文本的水平對齊方式
line-height: 文本行高
vertical-align: 文本所在行高的垂直對齊方式
text-indent: 文本縮進
letter-spacing: 添加字母之間的空白
word-spacing: 添加每個單詞之間的空白
text-transform: 屬性控制文本的大小寫
text-overflow: 文本溢出樣式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--<link href="cc2.css" rel="stylesheet" type="text/css">-->
<style>
div {
width: 100px;
height: 100px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div>索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧</div>
</body>
</html>
text-decoration: 文本的裝飾
text-shadow:文本陰影
word-wrap:自動換行
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
p {
width: 150px;
height: 160px;
background-color: #FFA500;
/*邊框陰影*/
box-shadow: 10px 10px 5px #888;
/*自動換行*/
word-wrap: break-word;
}
h1 {
text-shadow: 5px 5px 5px #888;
}
</style>
</head>
<body>
<p>
When you are old and grey and full of sleep,And nodding by the fire, take down this book,And slowly read, and dream of the soft look
</p>
<h1>索寧</h1>
</body>
</html>
a {
text-decoration: none;
/*去除a標簽下劃線*/
}
4. 背景屬性
background-color: 背景顏色
background-image 設置圖像為背景
background-position 設置背景圖像的位置坐標
background-repeat 設置背景圖像不重復平鋪
background-attachment 背景圖像是否固定或者隨著頁面的其余部分滾動
background 簡寫
5. 列表屬性
list-style-type: 列表項標志的類型
list-style-image:將圖象設置為列表項標志
list-style-position:列表項標志的位置
list-style:縮寫
1. 邊框
border-style:邊框樣式
border-color:邊框顏色
border-width:邊框寬度
border-radius:圓角
border: 簡寫
box-shadow:邊框陰影
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
div {
border:2px solid;
border-radius:25px;
width: 140px;
}
</style>
</head>
<body>
<div>
點贊哦!dear.
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.radius1 {
display: inline-block;
width: 100px;
height: 100px;
background-color: yellow;
border-radius: 20px;
}
.radius2 {
display: inline-block;
width: 100px;
height: 100px;
background-color: red;
border-radius: 20px 35px;
}
.radius3 {
display: inline-block;
width: 100px;
height: 100px;
background-color: blue;
border-radius: 20px 35px 50px;
}
.radius4 {
display: inline-block;
width: 100px;
height: 100px;
background-color: green;
border-radius: 20px 35px 50px 60px;
}
</style>
</head>
<body>
<div>
<span class="radius1"></span>
<span class="radius2"></span>
<span class="radius3"></span>
<span class="radius4"></span>
</div>
</body>
</html>
邊框實現各種三角符號:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.triangle-one {
display: inline-block;
border-top: 50px red solid;
border-right: 50px green solid;
border-bottom: 50px yellow solid;
border-left: 50px blue solid;
}
.triangle-two {
display: inline-block;
border-top: 0 red solid;
border-right: 50px green solid;
border-bottom: 50px yellow solid;
border-left: 50px blue solid;
}
.triangle-stree {
display: inline-block;
border-top: 50px red solid;
border-right: 0 green solid;
border-bottom: 50px yellow solid;
border-left: 50px blue solid;
}
.triangle-four {
display: inline-block;
border-top: 50px red solid;
border-right: 0 green solid;
border-bottom: 0 yellow solid;
border-left: 50px blue solid;
}
.triangle-five {
display: inline-block;
border: 50px transparent solid;
border-top: 50px red solid;
}
.triangle-six {
display: inline-block;
border: 50px transparent solid;
border-bottom: 50px yellow solid;
}
.triangle-seven {
display: inline-block;
border: 50px transparent solid;
border-top: 60px red solid;
border-right: 0;
}
.triangle-eight {
display: inline-block;
border: 50px transparent solid;
border-left: 30px yellow solid;
border-bottom: 0;
}
</style>
</head>
<body>
<div class="triangle-one"></div>
<div class="triangle-two"></div>
<div class="triangle-stree"></div>
<div class="triangle-four"></div>
<div class="triangle-five"></div>
<div class="triangle-six"></div>
<div class="triangle-seven"></div>
<div class="triangle-eight"></div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.back {
width: 1000px;
height: 1000px;
margin: 0 auto;
background-color: #ddd;
position: relative;
}
.back-in {
position: absolute;
width: 1020px;
height: 45px;
left: -20px;
top: 50px;
background-color: #2F4F4F;
}
.back-img {
border: 20px solid transparent;
border-top: 10px solid dimgrey;
border-right: 0;
display: inline-block;
position: absolute;
top: 95px;
left: -20px;
}
.back-font {
line-height: 9px;
margin-left: 30px;
color: white;
}
</style>
</head>
<body>
<div class="back">
<div class="back-in"><h3 class="back-font">妹子求關注 ^.^</h3></div>
<div class="back-img"></div>
</div>
</body>
</html>
2.★ 盒子模型
一個標準的盒子模型:
padding:用于控制內容與邊框之間的距離;
margin: 用于控制元素與元素之間的距離;
一個參數,應用于四邊。
兩個參數,第一個用于上、下,第二個用于左、右。
三個參數,第一個用于上,第二個用于左、右,第三個用于下。
邊框在默認情況下會定位于瀏覽器窗口的左上角,但是并沒有緊貼著瀏覽器的窗口的邊框,這是因為body本身也是一個盒子,外層還有html,
在默認情況下,body距離html會有若干像素的margin,所以body中的盒子不會緊貼瀏覽器窗口的邊框了。
解決方法:
body {
margin: 0;
}
3.★ display
4. visibility
5.★ float 浮動
讓一行顯示兩個塊級標簽,會脫離文檔流
clear 清除浮動:
6. clip 剪裁圖像
rect 剪裁定位元素:
7. overflow 設置當對象的內容超過其指定高度及寬度時如何顯示內容
8.★ position 規定元素的定位類型
9. z-index 元素層疊順序
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.z-index1 {
width: 100px;
height: 100px;
background-color: yellow;
position: absolute;
z-index: -1;
}
.z-index2 {
width: 100px;
height: 100px;
background-color: red;
position: absolute;
top: 20px;
left: 20px;
z-index: 5;
}
</style>
</head>
<body>
<div class="z-index1"></div>
<div class="z-index2"></div>
</body>
</html>
10. outline 邊框輪廓
11. zoom 縮放比例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.zoom1 {
zoom: 100%;
}
.zoom2 {
zoom: 150%;
}
.zoom3 {
zoom: 200%;
}
</style>
</head>
<body>
<div class="zoom1">Nick 100%</div>
<div class="zoom2">Nick 200%</div>
<div class="zoom3">Nick 300%</div>
</body>
</html>
12. cursor 鼠標的類型形狀
鼠標放在以下單詞上,There will be a miracle:
url: 自定義光標
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--<link href="cc2.css" rel="stylesheet" type="text/css">-->
<style>
body {
cursor: url("mouse.png"), auto;
/*圖片地址:http://images.cnblogs.com/cnblogs_com/suoning/845162/o_mouse.png*/
}
</style>
</head>
<body>
<div><img src="http://images.cnblogs.com/cnblogs_com/suoning/845162/o_ns.png" height="100%" width="100%"></div>
</body>
</html>
Auto: 默認
Default: 默認
e-resize
ne-resize
nw-resize
n-resize
se-resize
sw-resize
s-resize
w-resize
Crosshair
Pointer
Move
text
wait
help
not-allowed
13. transform、transition 動畫效果
transform 轉換,變形
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>nick</title>
<meta charset="utf-8" />
<style type="text/css">
div {
border: 1px solid black;
height: 30px;
width: 30px;
background-color: yellow;
/*transform-origin: 50px 50px;*/
transform-origin: left;
transform: rotate(50deg);
/*transform: skew(50deg,50deg);*/
/*transform: translate(50px,50px);*/
/*transform: scale(2);*/
}
</style>
</head>
<body>
<div></div>
</body>
</html>
Transition 平滑過渡
#property 指定屬性對應類型
1、color: 通過紅、綠、藍和透明度組件變換(每個數值單獨處理),如:background-color,border-color,color,outline-color等CSS屬性;
2、length:真實的數字,如:word-spacing,width,vertical- align,top,right,bottom,left,padding,outline-width,margin,min-width,min- height,max-width,max-height,line-height,height,border-width,border- spacing,background-position等屬性;
3、percentage:真實的數字,如:word-spacing,width,vertical- align,top,right,bottom,left,min-width,min- height,max-width,max-height,line-height,height,background-position等屬性;
4、integer 離散步驟(整個數字),在真實的數字空間,以及使用floor()轉換為整數時發生,如:outline-offset,z-index等屬性;
5、number真實的(浮點型)數值,如:zoom,opacity,font-weight等屬性;
6、transform list。
7、rectangle:通過x、 y、 width和height(轉為數值)變換,如:crop;
8、visibility:離散步驟,在0到1數字范圍之內,0表示“隱藏”,1表示完全“顯示”,如:visibility;
9、shadow:作用于color、x、y、和blur(模糊)屬性,如:text-shadow;
10、gradient:通過每次停止時的位置和顏色進行變化。它們必須有相同的類型(放射狀的或是線性的)和相同的停止數值以便執行動畫,如:background-image;
11、paint server (SVG):只支持下面的情況:從gradient到gradient以及color到color,然后工作與上面類似;
12、space-separated list of above:如果列表有相同的項目數值,則列表每一項按照上面的規則進行變化,否則無變化;
13、a shorthand property:如果縮寫的所有部分都可以實現動畫,則會像所有單個屬性變化一樣變化。
#支持執行transition效果的屬性
Property Name Type
background-color as color
background-position as repeatable list of simple list of length, percentage, or calc
border-bottom-color as color
border-bottom-width as length
border-left-color as color
border-left-width as length
border-right-color as color
border-right-width as length
border-spacing as simple list of length
border-top-color as color
border-top-width as length
bottom as length, percentage, or calc
clip as rectangle
color as color
font-size as length
font-weight as font weight
height as length, percentage, or calc
left as length, percentage, or calc
letter-spacing as length
line-height as either number or length
margin-bottom as length
margin-left as length
margin-right as length
margin-top as length
max-height as length, percentage, or calc
max-width as length, percentage, or calc
min-height as length, percentage, or calc
min-width as length, percentage, or calc
opacity as number
outline-color as color
outline-width as length
padding-bottom as length
padding-left as length
padding-right as length
padding-top as length
right as length, percentage, or calc
text-indent as length, percentage, or calc
text-shadow as shadow list
top as length, percentage, or calc
vertical-align as length
visibility as visibility
width as length, percentage, or calc
word-spacing as length
z-index as integer
鼠標放在以下圖片上,There will be a miracle:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>nick</title>
<meta charset="utf-8" />
<style type="text/css">
.img-see-2016-7-2 {
background-image: url("http://images.cnblogs.com/cnblogs_com/suoning/845162/o_sea.jpg");
background-size: 660px;
background-repeat: no-repeat;
height: 300px;
width: 600px;
transition-duration: 30s;
transition-timing-function: ease;
transition-property: background-size;
}
.img-see-2016-7-2:hover {
background-size: 2000px;
}
</style>
</head>
<body>
<div class="img-see-2016-7-2"></div>
</body>
</html>
作者:suoning
原文鏈接:https://www.cnblogs.com/suoning/p/5625582.html
ue 橫向滾動
<div class="slide-box">
<div class="slide-within">
<div class="slide-item" v-for="(item,index) in listData" :key="index">{{ index + item.label }}</div>
</div>
</div>
.slide-box {
margin-top: 200px;
overflow: hidden;
}
.slide-within {
display: -webkit-box;
overflow-x: scroll;
-webkit-overflow-scrolling: touch;
padding-bottom: 10px;
margin-bottom: -10px;
}
.slide-item {
width: 200px;
height: 200px;
border: 1px solid #ccc;
margin-right: 30px;
}
js 代碼
家好,我是四川新華電腦學院小張,
這篇文章講解Html的相關知識,如果想從零開始學習php編程的小伙伴,請從淼哥的第一篇文章看!
上次文章講解的是DTD,也就是我們常說的DOCTYPE。
我們繼續講解。
<!DOCTYPE html>-------------------------DOCTYPE 聲明了文檔類型
<html> ------------------------------------文檔類型html開始標記
<head> -----------------------------------頭部標記
<title>我的第一個標題</title>
</head> ----------------------------------頭部結束標記
<body> ---------------------------------文件主體
<h1>我的第一個標題</h1>
<p>我的第一個段落。</p>
</body> ----------------------------------文件主體結束
</html> ----------------------------------文檔類型html結束標記
這個是我們上次講解的html架構。
接著我們繼續講解。
html標簽
?寫法<html></html>
HTML標簽是HTML文檔的根標簽,在HTML中標簽是一層嵌套一層的,而<HTML>標簽是根標簽(最外面一層的標簽),所有其他的標簽都寫在這個標簽中。
根標簽我們可以理解為最外層的標簽。(看上面的結構)
文檔頭信息
HTML又包含head標簽和body標簽,其中head標簽中設置文檔頭信息,body標簽中設置文檔的內容。
<head> 標簽用于定義文檔的頭部,它是所有頭部元素的容器。
<head> 中的元素可以引用腳本、指示瀏覽器在哪里找到樣式表、提供元信息等等。
下面這些標簽可用在 head 部分:<base>, <link>, <meta>, <script>, <style>, 以及 <title>。
那么怎么理解元信息呢?比如對于網頁本身的一些描述,該網頁的標題?該網頁的描述,該網頁用的什么字符編碼!等等,這些信息描述著網頁,用戶又看不到這些信息。
比如某個人的性別,姓名,當你看到這個人,可以看到外貌,身高,穿衣服的顏色。但是你并不知道這個人的姓名,有的也不知道性別。尤其像某些中性一點的長相。是吧。元信息不會渲染,但是屬于該網頁的信息。
base標簽
(該標簽應該學習了a img link form這幾個標簽之后在學習,看不懂沒關系,可以先了解)
base標簽,是嵌套在head標簽中的一個標簽。這個標簽是一個可選標簽,也就是可以有,也可以沒有!
<base> 標簽為頁面上的所有鏈接規定默認地址或默認目標。
通常情況下,瀏覽器會從當前文檔的 URL 中提取相應的元素來填寫相對 URL 中的空白。比如:我有個<a href='aa.html'>標簽,那么瀏覽器會從當前文檔的url,比如當前文檔的url是www.xxxx.com/aa/bb/cc.html,瀏覽器會把www.xxxx.com/aa/bb/路徑拿出來,和aa.html組成新的url,那么這個超鏈接就會變成www.xxxx.com/aa/bb/aa.html。
使用 <base> 標簽可以改變這一點。
如果我們將base設置成為其他的url。<base />那么,還是<a href='aa.html'>標簽,就會把http://www.myweb.com/i/這個路徑拿出來和aa.html組成新的url地址。那么這個url超鏈接就會變成http://www.myweb.com/i/a.html這個鏈接了。
瀏覽器隨后將不再使用當前文檔的 URL,而使用指定的基本 URL 來解析所有的相對 URL。這其中包括 <a>、<img>、<link>、<form> 標簽中的 URL。
base標簽的用法
<base /> ------必選屬性。(你有這個標簽,就必須擁有這個屬性)
<base target="_blank" /> ------------------可選屬性。target意思是目標,打開超鏈接的方式,
當然也可以將兩個屬性寫到一個base標簽中。
<base target="_blank"/>
默認target的屬性是_self,也就是點擊超鏈接,在當前頁面的框架中打開。(為什么不是當前頁面呢?因為頁面有可能嵌套在框架里)
link標簽
<link> 標簽定義文檔與外部資源的關系。 也就是說定義外部CSS文件存放的位置。因為如果將CSS全部寫在網頁中,這樣顯的頁面太亂,一般都是單獨存放在一個CSS 文件中的。
<link> 標簽最常見的用途是鏈接樣式表CSS。
用法: <head> <link rel="stylesheet" type="text/css" href="test.css"></head>
meta標簽
<meta> 元素可提供有關頁面的元信息(meta-information),針對搜索引擎和更新頻度的描述和關鍵詞。
<meta> 標簽位于文檔的頭部,不包含任何內容。
<meta> 標簽的屬性定義了與文檔相關聯的名稱/值對。
meta標簽的作用有:搜索引擎優化(SEO),定義頁面使用語言,自動刷新并指向新的頁面,實現網頁轉換時的動態效果,控制頁面緩沖,網頁定級評價,控制網頁顯示的窗口等!
由于meta信息相對比較復雜我們將在以后HTML高級課程中講解
最常用meta標簽是:
<meta charset=“utf-8”/>
設置頁面編碼寫法。(頁面編碼注意,要設置的編碼和文檔的編碼統一,否則會出亂碼)
具體編碼以后的文章講解。
script標簽
<script> 標簽用于定義客戶端腳本,比如 JavaScript。
script 元素既可以包含腳本語句,也可以通過 src 屬性指向外部腳本文件。
必需的 type 屬性規定腳本的 MIME 類型。
JavaScript 的常見應用是圖像操作、表單驗證以及動態內容更新。
用法<script type="text/javascript">document.write("Hello World!") ></script> 以后學javascript將會用到,這里只做了解。
style標簽
<style> 標簽用于為 HTML 文檔定義樣式信息。(內聯CSS樣式)
在 style 中,您可以規定在瀏覽器中如何呈現 HTML 文檔。
type 屬性是必需的,定義 style 元素的內容。唯一可能的值是 "text/css"。
用法<head> <style type="text/css"> h1 {color:red} p {color:blue} </style> </head>
該標簽將會在學習CSS時用到,這里只做了解
title標簽
<title> 元素可定義文檔的標題。
瀏覽器會以特殊的方式來使用標題,并且通常把它放置在瀏覽器窗口的標題欄或狀態欄上。
同樣,當把文檔加入用戶的鏈接列表或者收藏夾或書簽列表時,標題將成為該文檔鏈接的默認名稱。
用法<title>網頁標題</title>
<title> 標簽是 <head> 標簽中唯一要求包含的東西。(必須有title標簽)
head 標簽總結
<head>標簽唯一要求包含的標簽是<title>其他那幾種可以包含也可以不包含,但是一般我們會包含<meta charset=“utf-8”>告訴瀏覽器我們的文件編碼是什么。
常用的標簽有:
<meta name=“keywords” content=“關鍵字”>告訴搜索引擎這個頁面的關鍵字
<meta name=“description” content=“頁面介紹”>告訴搜索引擎這個頁面的簡介
meta標簽,會在Html高級部分繼續講解。
<body>頁面主體信息
body 元素包含html的所有顯示web內容(比如文本、超鏈接、圖像、表格和列表等等。)
Body中可以使用塊級標簽和內聯標簽來顯示文檔結構
塊級標簽:h1~h6,p,div,table,ul,dl,from標簽等
內聯標簽:a,img,span,I,strong,select標簽等
什么塊級標簽(元素)呢?塊級標簽和內聯標簽區別是什么?
塊級元素(block)特性:總是獨占一行
內聯元素(inline)特性:和相鄰的內聯元素在同一行。
標簽和元素是一個意思!
<body>中包含的標簽?
標題標簽
通過<h1>~<h6>六個標簽定義不同大寫的標簽。
文本格式化標簽
早期編寫html代碼的時候,那個時候css用的很少,所以有一些標簽來文本格式化。現在基本都用CSS來格式化文本的大小顏色粗體等等。
而更多時候使用這些標簽來進行占位,利用CSS來渲染這些標簽。常用的是span。
html中的注釋
注釋用來說明、注解、注釋代碼。給人看的不會被執行。
格式為:<!– 注釋內容-->
瀏覽器頁面不會被顯示,而頁面源代碼中可以看到注釋的內容。因為項目越大,或者你的頁面越大,當時可能你能看懂。時間長了肯定看不明白。如果有注釋的話,可以馬上理解當時為什么要這么做。
水平線
在HTML代碼中加入一條水平線利用<hr />來操作。
段落標簽-<p>
瀏覽器會自動地在段落的前后添加空行,一般用在大段的文章。
換行標簽<br/>
<br/>標簽可以實現換一個新行 ,正常來說,你在編寫html頁面的時候,無論怎么換行,在頁面用瀏覽器打開的時候,是不會換行的,如果加入了<br/>標簽,瀏覽器就會認為這里該換行顯示了。
鏈接<a>標簽
HTML 使用超級鏈接與網絡上的另一個文檔相連。
幾乎可以在所有的網頁中找到鏈接。點擊鏈接可以從一張頁面跳轉到另一張頁面。
超鏈接可以是一個字,一個詞,或者一組詞,也可以是一幅圖像,您可以點擊這些內容來跳轉到新的文檔或者當前文檔中的某個部分。
當您把鼠標指針移動到網頁中的某個鏈接上時,箭頭會變為一只小手。
我們通過使用 <a> 標簽在 HTML 中創建鏈接。
有兩種使用 <a> 標簽的方式:
1、通過使用 href 屬性 - 創建指向另一個文檔的鏈接
<a href=“鏈接的文件名” target=“_blank”>鏈接名</a>
2、通過使用 name 屬性 - 創建文檔內的書簽
一般錨點鏈接主要用于網頁太長了,想瀏覽的那個位置需要滾輪滾動好幾下才能到達那個位置,而使用錨點(書簽)直接可以準確的跳轉到你想去的位置。
<a name=“文檔標簽名”>文檔標簽</a>
文檔中對錨進行命名(創建一個書簽)
<a href=“#tips”>鏈接名</a>
同一個文檔中創建指向該錨的鏈接用關鍵字#+錨名字
<a >有用的提示</a>
也可以鏈接到其他網絡上的頁面錨的鏈接
圖像<img>
可以使用img標簽在頁面上顯示一張圖片。
格式:
<img src=“圖片路徑” width=“寬” height=“高” alt=“圖片無法顯示時的提示”title=“鼠標放圖片上的提示”/>
備注:一般只設置寬即可,瀏覽器會根據圖片大小進行縮放。如果強行設置寬、高,有的時候圖片會失真。
列表標簽
列表標簽分為有序標簽和無序標簽
當然、有序列表前面也可以更改序號,需要在CSS中學習改變序號的方法。
二級列表<dl>標簽
表格標簽-table
Table標簽用來制作表格,表格由若干個行<tr>組成,每一行又由若干個單元格<td>組成。
Table標簽中使用tr標簽定義行,td標簽定義一行中的一個列。如:定義一個一行四列。
表格的表頭使用 <th> 標簽進行定義。
大多數瀏覽器會把表頭顯示為粗體居中的文本:
<table>標簽的cellpadding 屬性規定單元邊沿與其內容之間的空白。
<table>標簽的cellspacing 屬性規定單元格之間的空間。
橫向合并單元格-colspan
表格-table-豎向-rowspan
內聯框架
可以使用iframe在頁面中在嵌入另外一個頁面。
分區標簽-div
Div是塊級標簽,主要是用來作為標簽容器,和規劃頁面結構(頁面布局)的
用法:
<div style="margin:auto;border:1px solid #f00;width: 300px;height: 600px"></div>
在很早以前,小編剛入行的時候,那個時候CSS不流行,頁面布局全部都用表格來做。那酸爽實在無法用言語來表達。而現在都是用CSS來進行頁面布局。這個div標簽頁是以后布局常用的標簽。
Span標簽
Span標簽是內聯標簽,沒有特殊功能。主要是用來做為文本的容器,span標簽主要是配合CSS來處理文字。
比如,我只想讓幾個文字編程紅顏色的,這個時候就可以用span標簽配合CSS來做了。
框架集-frameset
我們可以使用frameset標簽把一個頁面窗口分隔成多個窗口,然后使用frame標簽為每一個窗口制定一個頁面
使用rows/cols的值規定每行或每列占據屏幕的面積,中間用逗號分隔。
frameset不能放在body中,如果放在body中不能顯示框架 !
在最新的html5中已經刪除了這個標簽了
實體
在 HTML 中,某些字符是預留的。
在 HTML 中不能使用小于號(<)和大于號(>),這是因為瀏覽器會誤認為它們是標簽。
比如我們想在網頁使用空格,直接按空格鍵是肯定不好使的,所以使用使用實體 !
音頻
<embed src="helloworld.swf" height=“100” width=“100”/>
<embed> 標簽是 HTML 5 中的新標簽。
使用embed標簽可以在網頁中嵌入Flash,Mid,MP3等嵌入式內容
現在html5出了很多新的標簽,以后會專門有講解html5的文章。
今天我們一起了解了html相關的很多標簽。其實都很簡單。只要自己動手做一做,就可以做出來了。如果想要做出精美的頁面,還是需要配合css來實現的哦。
明天我們繼續講解html的一些其他相關知識。手寫不宜!請給小編點個贊!十分感謝。
*請認真填寫需求信息,我們會在24小時內與您取得聯系。