HTML03—样式、BOX模型、背景色

CSS

  • 方式
    内联方式:样式定义在单个HTML元素中
    内部样式表:定义在HTML页的头元素中
    外部样式表:将样式定义在外部的css文件中,HTML页引用
    相同的样式,如果重复定义,以最后一次为准
  • 类选择器
    .className{ color:red; }
    可用于多个不同元素使用同样的样式使用类选择器
    类选择器和元素选择器结合:元素选择器.className{}
  • id选择器

id{}

04.css

p {
    background-color: silver;   
}

HTML页面

<title>css样式</title>
<link rel="stylesheet" type="text/css" href="04.css">
<style type="text/css">
h2 {
    color:green;
}
.s1 {
    color:red;
}
.s2 {
    font-size: 25pt;
}
#shopCar {
    color:red;
}
#d1 > p{
    color:blue;
}
<!--未被访问的超链接-->
a:link{
    color:blue;
}
<!--已被访问的超链接-->
a:visited {
    color:red;
}
<!--鼠标悬停在元素上-->
a:hover{
    color:yellow;
}
</style>
</head>
<body>
    <h1 style="color:red;font-size:20pt;">css的使用</h1>
    <h2>内部样式使用</h2>
    <p>外部样式使用</p>
    <p>先创建一个<span class="s1">css</span>文件</p>
    <!--class类选择器  -->
    <p>将css文件引入</p>
    <p class="s2">可以使用class的类选择器选择元素,设置样式</p>
    <h2 id="shopCar">购物车</h2>
    <div id="d1">
        div标签
        <p>这里是段落标签</p>
    </div>
    <a href="#">伪类选择器</a>
</body>
</html>
  • border
    border:width值 style值 color值
    单位:-%:百分比; -pt:磅(1pt=1/72英寸);-px:像素(屏幕的一个点);-em:1em当前字体,2em当前字体2倍
  • 文本格式化
    font-size:字体大小
    font-weight:字体加粗(normal/bold)
    text-align:排列(left/right/center)
    line-height:行高
    text-indent:2em;首行缩进2
p{
    text-align:center;
    color:blue;
    line-height:1.6em;
    text-wight:bold;
}
  • BOX模型
    padding:内边框边距
    margin:外边框边距
    BOX模型图解
  • 背景色
    background-color:为元素设置背景色
    背景图片background-image: url(“images/ceci_9.gif”);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
.x-form .x-btn{ height:25px; width:95px; line-height:25px; color:#000; background:#414143 url(images/btn_02.jpg); border:0px; margin-left:5px; } .x-form .x-brnull{ border-right:0px; } .x-msg{ background:#EEF5FF; margin:0px auto; color:#000; border:1px solid #ccc; } .x-msg A{ text-decoration:none; color:red; } .x-form .x-blnull{ border-left:0px; } .x-form-title,.x-form-title td{ font-weight:bold; color:#000; background:#eee; border:1px solid #dcdcdc; } .x-form-bBack td{ background:url(images/bg6.jpg) repeat-x; color:#FFF; border:1px solid #4D4D4D; } .x-form-bGreen td{ background:url(pic/bg14.jpg) repeat-x; } .x-form-title span,.x-form-title td span{ margin-left:10px; } /**列表***/ .x-list{ width:100%; font-size:12px; } /***列表Head**/ .x-list .x-head td,.x-list .x-head th{ /***background:url(images/head_bg.gif) repeat-x;**/ background:url(pic/bg14.jpg) repeat-x; height:27px; line-height:27px; text-align:center; font-weight:bold; } /**行的默认颜色**/ .x-list td{ padding-left:3px; height:27px; line-height:27px; border:1px solid #dcdcdc; } .x-list .x-sRow td{ background:#F8F8F8; } /**偶数行背景颜色***/ .x-list .x-dRow td{ background: #FBECC6; } /**选中TD背景颜色**/ .x-list .x-stRow td{ background:#d5effc url(images/td_over.png) repeat-x; } /**内容显示位置 left center right**/ .x-list .x-l{ text-align:left; } .x-list .x-c{ text-align:center; } .x-list .x-l{ text-align:right; } /**分页**/ .x-list .x-page{ height:35px; line-height:35px; background:#eee; text-align:center; } .x-list .x-page A{ margin-left:5px; text-decoration:none; color:#004A9B; } .x-list .x-page A:hover{ color:#404040; } .x-list td .x-a A{ text-decoration:none; color:#000; } .x-list td .x-a A:hover{ text-decoration:underline; color:#999; } 比较实用的box样式表单
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值