惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
博客园 - 【当耐特】
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
罗磊的独立博客
T
Tenable Blog
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Security Archives - TechRepublic
Security Archives - TechRepublic
博客园 - 司徒正美
L
LINUX DO - 最新话题
AI
AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Secure Thoughts
IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
W
WeLiveSecurity
博客园_首页
Forbes - Security
Forbes - Security
博客园 - 聂微东
宝玉的分享
宝玉的分享
Google DeepMind News
Google DeepMind News
V
Visual Studio Blog
Microsoft Security Blog
Microsoft Security Blog
Vercel News
Vercel News
小众软件
小众软件
Webroot Blog
Webroot Blog
V2EX - 技术
V2EX - 技术
博客园 - 叶小钗
T
The Exploit Database - CXSecurity.com
TaoSecurity Blog
TaoSecurity Blog
L
Lohrmann on Cybersecurity
I
InfoQ
J
Java Code Geeks
P
Privacy International News Feed
Spread Privacy
Spread Privacy
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
D
Docker
P
Proofpoint News Feed
B
Blog
Cisco Talos Blog
Cisco Talos Blog
M
MIT News - Artificial intelligence
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Threat Research - Cisco Blogs
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements

博客园 - sleepy

Android 下进行单元测试 Test run failed:Instrumentation run failed due to 'java.lang.ClassNotFoundException' 使用Maven自动部署Tomcat 6和Tomcat 7下Web应用 windows 7下命令行修改用户密码 VMWare Workstation 中Guest OS使用Bridge方式上网故障诊断 java下运行windows命令行程序(批处理文件)示例 - sleepy - 博客园 不用安装Oracle Client如何使用PLSQL Developer 新的 好用的 免费的 功能强大的Oracle 客户端 MySQl客户端访问软件 VPC 2007 SP1下安装Windows虚拟机要点(关键字:VM,Virtual PC, 网络,共享文件,windows 2003, vista, Window XP) tomcat 设置初始内存大小(默认的可是太小了,容易内存溢出) - sleepy - 博客园 测试显示内存使用情况的JSP脚本 在Virtual PC 2007 SP1上安装linux ubuntu 810 如何解决eclipse编辑器,console 汉字显示为乱码?? MySQL内置命令导出数据库 iBatis 数据库空值的映射处理 设置MySQL 超时等待时间 Java中访问My SQL如何显示SQL中的汉字 如何高效率修改bug 如何在MySql中记录SQL日志(例如Sql Server Profiler)
CSS guideline
sleepy · 2010-03-18 · via 博客园 - sleepy

1. Common Selectors
1.1. type(类型)<element selector or simple>
particular type of element, such as a <p> <a>...

p {color: black;}
a {text-decoration: underline;}

1.2. descendant(后代).target the descendants of a particular element or group
of elements. A descendant selector is indicated by a space between two other selectors

p a {text-decoration: none;}

1.3. ID selector & class selector
will target elements with the corresponding ID
or class name. ID selectors are identified using a hash character; class selectors are identified
with a period.

#intro {font-weight: bold;}
.datePosted {color: green;}
<p id="intro">Some Text</p>
<p class="datePosted">24/3/2006</p>

1.4. Pseudo-classes
to style an element based on something other than the structure of the document
/* makes all unvisited links blue */
a:link {color:blue;}
/* makes all visited links green */
a:visited {color:green;}
/* makes links red when hovered or activated */
a:hover, a:active {color:red;}
/* makes table rows red when hovered over */
tr:hover {background-color: red;}
/* makes input elements yellow when focus is applied */
input:focus {background-color:yellow;}


2. The universal selector
like a wildcard, matching all the available elements
* {
padding: 0;
margin: 0;
}

3. Advanced selectors (IE 6 not support)
3.1. child selector
Whereas a descendant selector
will select all the descendants of an element, a child selector only targets the element’s
immediate descendants

#nav > li {font-weight: bold;}
“fake” a child selector that works in IE 6 and below by using the universal selector.
#nav li {font-weight: bold;}
#nav li * {font-weight: normal;}

3.2. adjacent sibling selectors
h1 + p {font-weight: bold;}

<h1>Main Heading</h1>
<p>First Paragraph</p>
<p>Second Paragraph</p>


3.3. Attribute selectors
attribute selector allows you to target an element based on the
existence of an attribute or the attribute’s value.

abbr[title] {border-bottom: 1px dotted #999;}
abbr[title]:hover {cursor: help;}

a[rel="nofollow"] {
background-image: url(nofollow.gif);
padding-right: 20px;
}

------------------------------------------------------------------------------
4. The cascade and specificity
two or more rules will target the same element. CSS handles such conflicts through a process known as the cascade.

So the cascade works in the following order of importance:
 User styles flagged as !important
 Author styles flagged as !important
 Author styles
 User styles
 Styles applied by the browser/user agent

4.1 Specificity
specificity is not calculated in base 10 but a high, unspecified, base number
style > ID > class > type(element)

5. Inheritance
Certain properties, such as color or font size, are inherited by the
descendants of the elements those styles are applied to.

p, div, h1, h2, h3, ul, ol, dl, li {color: black;}
when you can just write this:
body {color: black;}

padding:10px 四个边均为10px
h1 {padding: 10px 2% 15px 20px} padding-top padding-right padding-bottom padding-left