css基础学习
2016-07-13 21:11
591 查看
css样式顺序
浏览器缺省设置外部样式表
内部样式表(位于 标签内部)
内联样式(在 HTML 元素内部)
继承
下面的是作用在h2的strong元素上:<h2>The strongly emphasized word in this subhead is<strong>blue</strong>.</h2>
h2 strong { color: blue; }
id 选择器和派生选择器
id为sidebar里面的p, h2元素格式:#sidebar p { font-style: italic; text-align: right; margin-top: 0.5em; } #sidebar h2 { font-size: 1em; font-weight: normal; font-style: italic; margin: 0; line-height: 1.5; text-align: right; }
下面是div元素id为inner:
div#inner {text-indent: 10%;}
类选择器
派生选择器fancy类下面的td元素:
.fancy td { color: #f60; background: #666; }
元素类选择
td表单里面的fancy类:td.fancy {
color: #f60;
background: #666;
}
td.fancy { color: #f60; background: #666; }
属性选择器
//所有包含title属性的元素 [title]{ color: red; } //所有title为 hehe的元素 [title=hehe] { border:5px solid blue; }
属性选择器在为不带有 class 或 id 的表单设置样式时特别有用:
input[type="text"] { width:150px; display:block; margin-bottom:10px; background-color:yellow; font-family: Verdana, Arial; } input[type="button"] { width:120px; margin-left:35px; display:block; font-family: Verdana, Arial; }
表单插入
外部:<head> <link rel="stylesheet" type="text/css" href="mystyle.css" /> </head>
内部:
<head> <style type="text/css"> hr {color: sienna;} p {margin-left: 20px;} body {background-image: url("images/back40.gif");} </style> </head>
相关文章推荐
- Web布局连载——两栏固定布局(五)
- [div+css]晒晒最新制作专题推广页模板
- 盒子模型
- CSS选择器
- CSS样式优先权
- [css] line-height 百分比单位和数值单位的区别
- Apple官网研究之使用Justify布局导航
- 关于前端的思考与感悟
- rem : web app适配的秘密武器
- jquery高级应用之Deferred对象
- 移动端点击事件全攻略,这里的坑你知多少?
- $q 实例分析 Angular 中的 Promise
- 浏览器中唤起native app || 跳转到应用商城下载
- Angular directive 实例详解
- 关于浮动与清除浮动,你应该知道的
- 数组reduce方法的高级技巧
- 设计更快的网页(三):字体和 CSS 调整
- 纯CSS制作的新闻网站中的文章列表