Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
篇文章主要講述了CSS樣式更改中的背景Background,這篇文章我們來談談字體設置Font&邊框Border的基礎用法。
<div style='font-family: sans-serif normal'></div>
可用字體:
Serif
Sans-serif
Monospace
Cursive
Fantasy
Times
Courier
<div style='font-style:normal'></div>
文本傾斜:
normal 文本正常顯示
italic 文本斜體顯示
oblique 文本傾斜顯示
<div style='font-variant:small-caps'></div>
normal 顯示標準字體。
small-caps 顯示小型大寫字母的字體。
<div style='font-weight:normal'></div>
normal 標準的字符
bold 粗體字符
bolder 更粗的字符
lighter 更細的字符
也可以使用數字表示,范圍為100~900
<div style='font-size:60px'></div>
smaller 變小
larger 變大
length 固定值
而且還支持百分比
首先說一下邊框風格,它的風格比較多,常用的一般是實線為主:
<div style='border-style:none'></div>
hidden 隱藏邊框
dotted 點狀邊框
dashed 虛線邊框
solid 實線邊框
double 雙線邊框
groove 3D凹槽邊框
ridge 3D壟狀邊框
inset 3D inset邊框
outset 3D outset邊框
邊框也有四面,所以也會有上下左右
所以有時候為了更精確定位并修改樣式可以使用:
border-top-style 上邊框樣式
border-right-style 右邊框樣式
border-bottom-style 下邊框樣式
border-left-style 左邊框樣式
先定義邊框的寬度 風格和顏色,然后定義邊框的其它屬性。
<div style='border-radius:25px;'></div>
2).邊框陰影
<div style='box-shadow:1px 2px 2px 2px red'></div>
參數含義:
邊框各個方向的大小和顏色
3).邊框圖片
<div style='border-image:url(1.png) 30 30 10 round'></div>
參數含義:
邊框圖片的路徑
圖片邊框向內偏移
圖片邊框的寬度
邊框圖像區域超出邊框的量
圖像邊框是否應平鋪(repeated)、鋪滿(rounded)或拉伸(stretched)。
這篇文章主要介紹了CSS樣式更改篇中的字體設置Font&邊框Border設置,希望讓大家對CSS選擇器有個簡單的認識和了解。
****看完本文有收獲?請轉發分享給更多的人****
IT共享之家
想要學習更多,請前往Python爬蟲與數據挖掘專用網站:http://pdcfighting.com/
ont 屬性可以用來作為 font-style, font-variant, font-weight, font-size, line-height 和 font-family 屬性的簡寫,或將元素的字體設置為系統字體。
font-family寫法示例:
<style>
p{
font-family: "幼圓";
}
</style>
</head>
<body>
<p>19級啟嘉班</p>
</body>
效果:
字是網頁展示的重要內容之一,所以對文字的修飾也是CSS重點關注的一部分, CSS提供了以下常用的樣式屬性來修飾文字。
color 用來設置文字顏色。
設置方式支持以下幾種格式
<style>
.box {
color: red;
}
</style>
<div class="box">文字顏色</div>
<style>
.box {
color: #ff0000;
}
.box1 {
color: #f00;
}
</style>
<div class="box">文字顏色</div>
<div class="box1">簡寫形式</div>
<style>
.box {
color: rgb(255, 0, 0);
}
</style>
<div class="box">文字顏色</div>
<style>
.box {
color: rgba(255, 0, 0, 0.5);
}
</style>
<div class="box">文字顏色</div>
font-size 屬性用來設置字體大小,單位通常為px 也可以為em,rem
單位的解釋
<style>
.box {
font-size: 30px;
}
</style>
<div class="box">文字大小</div>
設置字體的粗細程度,常用的屬性有 normal 和 bold 兩個值。
可以用以下值表示,也可以用數字表示。
值 | 意義 |
normal | 正常粗細,和400值相等 |
bold | 加粗,與700數值相等 |
lighter | 比 正常粗細還細, 不常用 |
bolder | 比 加粗還粗,不常用 |
100 200 300 400 500 600 700 800 900 | 使用數字定義字體粗細 |
inherit | 從父元素繼承字體粗細 |
<style>
.box_normal {
font-weight: normal;
}
.box_bold {
font-weight: bold;
}
.box_lighter {
font-weight: lighter;
}
.box_bolder {
font-weight: bolder;
}
.box_number {
font-weight: 600;
}
</style>
<body>
<div class="box_normal">font-weight演示:正常粗細</div>
<div class="box_bold">font-weight演示,加粗</div>
<div class="box_lighter">font-weight演示,更細</div>
<div class="box_bolder">font-weight演示, 更粗</div>
<div class="box_number">font-weight演示, 數字</div>
</body>
設置字體的傾斜程度
值 | 意義 |
normal | 正常字體, 不帶傾斜效果 |
italic | 傾斜字體(常用,使用傾斜字體) |
oblique | 傾斜字體(用常規字體模擬傾斜,不常用) |
<style>
.box1 {
font-style: normal;
}
.box2 {
font-style: italic;
}
.box3 {
font-style: oblique;
}
</style>
<body>
<div class="box1">正常字體</div>
<div class="box2">傾斜字體</div>
<div class="box3">傾斜字體2</div>
</body>
設置文本的修飾線的樣式
示例 | 意義 |
none | 無線(a標簽去除下劃線會用到) |
underline; | 下劃線 |
line-through; | 刪除線 |
…等等 | 還有很多,可自行百度 |
<style>
.decoration-none {
text-decoration: none;
}
.decoration-underline {
text-decoration: underline;
}
.decoration-line-through {
text-decoration: line-through;
}
</style>
<body>
<div class="decoration-none">無線修飾</div>
<div class="decoration-underline">下劃線</div>
<div class="decoration-line-through">刪除線</div>
</body>
指定使用的字體族,操作系統一般自帶很多字體;
例如:window操作系統中的 ‘微軟雅黑’ ,黑體等。
字體文件的格式有很多,比如 eot,woff2,woff,ttf,svg等。
font-family 可以一次指定多個字體, 后面的字體屬于后備字體,只有前面的字體沒有找到,才會使用后面的字體。
<style>
div {
font-family: serif, "Time New Roman", "微軟雅黑"
}
</style>
<body>
<div>字體</div>
</body>
自定義字體
某些時候,我們的字體比較個性化,或者我們的字體是一個圖標字體(一種用符號表示圖片的方式)。那么此時,需要我們使用 @font-face 自定義字體
自定義的字體一般是隨著網頁發布在服務器端,操作系統中并沒有。
推薦一個比較好用的字體庫網站:https://www.iconfont.cn/(具體使用方式請自行百度)。
*請認真填寫需求信息,我們會在24小時內與您取得聯系。