首页
/
每日頭條
/
生活
/
盒子模型三大屬性
盒子模型三大屬性
更新时间:2026-01-27 00:02:54

什麼是盒子模型?

盒子模型三大屬性(盒子模型-第六章)1

盒子模型如圖所示

1、邊框:

border-color

border-width

border-style

屬性 說明 示例

border-top-color 上邊框顔色 border-top-color:#369;

border-right-color 右邊框顔色 border-right-color:#369;

border-bottom-color 下邊框顔色 border-bottom-color:#fae45b;

border-left-color 左邊框顔色 border-left-color:#efcd56;

border-color 四個邊框為同一顔色 border-color:#eeff34;

上、下邊框顔色:#369

左、右邊框顔色:#000 border-color:#369 #000;

上邊框顔色:#369

左、右邊框顔色:#000

下邊框顔色:#f00 border-color:#369 #000 #f00;

上、右、下、左邊框顔色:

#369、#000、#f00、#00f border-color:#369 #000 #f00 #00f;

邊框粗細:border-width

thin;

medium;

thick;

像素值;

邊框樣式: border-style

none;

hidden;

dotted;

dashed;

solid;

double;

border的簡寫:

border:1px solid #3a6587;

border: 1px dashed red;

2、外邊距:margin

margin-top;

margin-right;

margin-bottom;

margin-left;

網頁居中對齊:margin:0px auto;

網頁居中對齊的必要條件:塊元素、固定寬度

3、内邊距:padding

padding-left

padding-right

padding-top

padding-bottom

4、在網頁上畫個圖形:

<!DOCTYPE html>

<html lang="en">

<head>

<title>圓角邊框</title>

</head>

<!-- 内部樣式表 -->

<style>

/* 圓 */

.one{

width:100px;

height:100px;

border:4px solid red;

border-radius: 100px;

}

/* 半圓形 */

/* 上半圓 */

.two{

width:200px;

height:100px;

background-color: red;

border-radius: 100px 100px 0 0;

}

/* 下半圓 */

.three{

width:200px;

height:100px;

background-color: red;

border-radius: 0 0 100px 100px;

}

/* 左半圓 */

.four{

width :100px;

height:200px;

background-color: red;

border-radius: 0 100px 100px 0

}

/* 右半圓 */

.five{

width :100px;

height:200px;

background-color: red;

border-radius: 100px 0 0 100px

}

/* 扇形 */

.six{

width :100px;

height:100px;

background-color: red;

border-radius: 100px 0 0 0

}

.seven{

width :100px;

height:100px;

background-color: red;

border-radius: 0 100px 0 0

}

.eigth{

width :100px;

height:100px;

background-color: red;

border-radius: 0 0 100px 0

}

.nine{

width :100px;

height:100px;

background-color: red;

border-radius: 0 0 0 100px

}

</style>

<body>

<div class="container">

<div class="one">

</div>

<br/>

<div class="two">

</div><br/>

<div class="three">

</div>

<div class="four">

</div>

<div class="five">

</div>

<div class="six">

</div><br/>

<div class="seven">

</div><br/>

<div class="eigth">

</div><br/>

<div class="nine">

</div><br/>

</div>

</body>

</html>

5、盒子陰影:

box-shadow:inset x-offset y-offset blur-radius color;

6、上示例:<html>

<head>

<title>美容熱賣品</title>

</head>

<link rel="stylesheet" href="meirongremai.css">

<body>

<div class="container">

<div class="title">

<h2>大家都喜歡買的美容品</h2>

</div>

<div class="list">

<ul>

<li><a href="#"><span>1</span>&nbsp;&nbsp;&nbsp;<span>雅詩蘭黛即時修護眼部精華霜15ml</span></a> </li>

<li><a href="#"><span>2</span>&nbsp;&nbsp;&nbsp;<span>伊麗莎白雅頓顯效複合活膚霜 75ml</span></a> </li>

<li><a href="#"><span>3</span>&nbsp;&nbsp;&nbsp;<span>OLAY玉蘭油多效修護霜 50g</span></a> </li>

<li><a href="#"><span>4</span>&nbsp;&nbsp;&nbsp;<span>巨型一号絲瓜水320ML</span></a> </li>

<li><a href="#"><span>5</span>&nbsp;&nbsp;&nbsp;<span>倩碧保濕潔膚水2号 200ml</span></a> </li>

<li><a href="#"><span>6</span>&nbsp;&nbsp;&nbsp;<span>比度克細膚淡印霜 30g</span></a> </li>

<li><a href="#"><span>7</span>&nbsp;&nbsp;&nbsp;<span>蘭芝 (LANEIGE)夜間修護鎖水面膜 80ml </span></a> </li>

<li><a href="#"><span>8</span>&nbsp;&nbsp;&nbsp;<span>SK-II護膚精華露 215ml </span></a> </li>

<li><a href="#"><span>9</span>&nbsp;&nbsp;&nbsp;<span>歐萊雅青春密碼活顔精華肌底液</span></a> </li>

</ul>

</div>

</div>

</body>

</html>

/* 去除所有内外邊距 */

*{

margin:0;

padding:0;

}

/* 去超鍊接的下劃線 */

a {

text-decoration: none;

}

/* 去小圓點 */

li{

list-style: none;

}

/* 整個布局背景設置 */

body{

background:#eee7e1;

}

/* 内容背景設置 */

.container{

background: #fff;

width: 400px;

margin:10px;

}

/* 标題 */

.title>h2{

background-color: #e6005a;

color:#fff;

font-size: 16px;

padding-left: 12px;

line-height:40px;

}

.list ul li{

font-size: 14px;

border-bottom:1px dashed #000;

}

/* 内容小圓圈s */

.list ul li span:first-child{

margin:2px;

/* span 标簽轉換成具有行内和塊元素特點 */

display :inline-block;

width: 19px;

height:28px;

background:#000;

border-radius: 50%;

color:#fff;

margin-left: 1px;

padding-left:10px;

}

li a:hover{

color:red;

}

li a:hover>span:first-child{

color:#e6005a

}

效果圖展示鍊接:file:///D:/ruanjian/VS/wenjianxiangmu/htmlSix/meirongremai.html

,
Comments
Welcome to tft每日頭條 comments! Please keep conversations courteous and on-topic. To fosterproductive and respectful conversations, you may see comments from our Community Managers.
Sign up to post
Sort by
Show More Comments
推荐阅读
草莓苗怎麼種植方法
草莓苗怎麼種植方法
草莓苗怎麼種植方法?品種:栽種草莓苗,需要選擇耐寒性較強且産量高的品種,我來為大家科普一下關于草莓苗怎麼種植方法?以下内容希望對你有幫助!草莓苗怎麼種植方法品種:栽種草莓苗,需要選擇耐寒性較強且産量高的品種。時間:草莓苗适宜在每年春季的3-...
2026-01-27
醬香雞翼的做法
醬香雞翼的做法
醬香雞翼的做法?清水一鍋,雞翅中冷水入鍋,中火煮開,雞翅煮至八分熟(不出血水)即可,出鍋,冷水沖洗幹淨,裝盤備用蔥、姜切片,蒜拍扁,備用,接下來我們就來聊聊關于醬香雞翼的做法?以下内容大家不妨參考一二希望能幫到您!醬香雞翼的做法清水一鍋,雞...
2026-01-27
搞笑笑話幽默段子
搞笑笑話幽默段子
搞笑笑話幽默段子?1.去理發,跟老闆細細交代:“前面多留點,後面盡量推幹淨,頭發要搞出内扣的感覺,一層一層往外剪,最好搞出蓬起來那種……”,我來為大家講解一下關于搞笑笑話幽默段子?跟着小編一起來看一看吧!搞笑笑話幽默段子1.去理發,跟老闆細...
2026-01-27
柿子與螃蟹一起吃會不會中毒
柿子與螃蟹一起吃會不會中毒
從前的日色變得慢車,馬,郵件都慢一生隻夠愛一個人從前的鎖也好看鑰匙精美有樣子你鎖了人家就懂了從前,人們圍坐在一起慢慢吃飯,淺淺談心,黃瓜有淡淡的甜,番茄是沙瓤流心。從前的人大都不知道“蘇丹紅”,不知道“瘦肉精”,他們日出而作,日落而息。他們...
2026-01-27
諸子百家哪一個學說讓你有所感悟
諸子百家哪一個學說讓你有所感悟
列子是先秦諸子中道家的關鍵人物,出生時間介于老莊之間,承上啟下,對道家思想的發展和推動做出了很大的貢獻。列子最被人津津樂道的莫過于他書中幾十篇短小精悍的寓言故事和"禦風而行"的傳說。而"禦風而行"由于賦予了列...
2026-01-27
Copyright 2023-2026 - www.tftnews.com All Rights Reserved