接上一篇:CSS入门学习笔记例题详解(一)
接下一篇:CSS入门学习笔记例题详解(三)






注意事项:

例题:


DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documenttitle>
<style>
.nav{
height: 41px;
width: 530px;
border-top: 3px solid #ff8500;
border-bottom: 1px solid #edeef0;
background-color: #fcfcfc;
}
.nav a {
display: inline-block;
color: #4c4c4c;
height: 41px;
font-size: 12px;
padding:10px 20px;
text-decoration: none;
}
.nav a:hover {
background-color: #fff;
color: #ff8500;
}
style>
head>
<body>
<div class="nav">
<a href="">设为首页a>
<a href="">手机新浪网a>
<a href="">移动客户端a>
<a href="">博客a>
<a href="">微博a>
<a href="">关注我a>
div>
body>
html>
原理和padding一样


注意:行内元素和行内块元素水平居中:



例题:

transparent是透明



DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documenttitle>
<style>
* {
text-align: center;
font-size: 14px "Helvetica Neue", Helvetica, Arial;
}
li {
width: 234px;
height: 340px;
border: 2px solid white;
}
.brick {
text-decoration: none;
width: 234px;
height: 300px;
padding: 20px 30px;
}
img {
width: 160px;
height: 160px;
padding: 0px 0px;
}
h3 {
width: 214px;
height: 21px;
color: #333333;
margin: 0px 10px 2px;
padding: 0px 0px;
}
.desc {
width: 214px;
height: 21px;
color: #b0b0b0;
margin: 0px 10px 10px;
font-size: 14px;
}
.price {
width: 214px;
height: 21px;
color: #FF6700;
margin: 0px 10px 14px;
}
style>
head>
<body>
<ul>
<li type="none">
<a href="#" class="brick">
<div class="figure">
<img src="小米手机.jpg" alt="">
div>
<h3>
Xiaomi 125
h3>
<p class="desc">小尺寸性能旗舰 | 徕卡影像p>
<p class="price">3999元起p>
a>
li>
ul>
body>
html>

DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documenttitle>
<style>
* {
padding: 0px;
margin: 0px;
}
.all {
border: 2px solid rgb(182, 179, 179);
width: 300px;
height: 210px;
}
.head {
width: 300px;
height: 50px;
border-bottom: 2px solid rgb(182, 179, 179);
line-height: 50px;
}
h3 {
font-weight: normal;
color: rgb(97, 91, 91);
padding: 0px 20px;
}
li {
color: rgb(97, 91, 91);
padding: 5px 10px 5px 30px;
}
style>
head>
<body>
<div class="all">
<div class="head">
<h3>品优购快报h3>
div>
<div class="body">
<ul type="none">
<li>【特惠】 爆款耳机5折秒li>
<li>【特惠】 爆款耳机5折秒li>
<li>【特惠】 爆款耳机5折秒li>
<li>【特惠】 爆款耳机5折秒li>
<li>【特惠】 爆款耳机5折秒li>
ul>
div>
div>
body>
html>
div{
width:200px;
height:200px;
border-radius:10px;
background-color:aqua;
}

例题:div显示一个圆


圆角矩形,把border-radius设置为高度的一半即可。
属性值可以写1个,也可以写4个

4. border-top-left-radius:10px;//只设置左上角为圆角边框,其他不变

例题:

