[CSS] DOM Hierarchy Pseudo Classes :first-child :last-child :nth-child (demystified)
DOM hierarchy pseudo-classes allow you to style specific elements based on where they fall in the hierarchy and what type of elements they are. You can also use :nth-child to target custom element patterns, like every other element.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link rel="stylesheet" href="styles.css">
<style>
ul {
list-style: none;
margin: 0;
padding: 0;
} li {
padding: 5px;
} /* li:first-child {
background-color: rgb(225, 231, 252);
}
li:last-child {
background-color: rgb(225, 231, 252);
}
li:nth-child(2) {
background-color: rgb(225, 0, 252);
}*/
/* The even child*/
/*li:nth-child(2n) {
background-color: gold ;
}*/ /* The odd child*/
/*li:nth-child(2n+1) {
background-color: darkred;
}*/ /* First 4 children */
li:nth-child(-n+4) {
background-color: cadetblue;
} /* Expect first three children*/
li:nth-child(n+4) {
background-color: lightgoldenrodyellow;
} /* Other psuedo classes:
* :nth-last-child
* :only-child
* :only-of-type
* :last-of-type
* :nth-of-type(an+b)
* :nth-last-of-type(an+b)
*/</style>
</head>
<body>
<ul>
<li><a href="#" target="_blank">target=_blank</a></li>
<li><a href="#" target="someFrame">target=someFrame</a></li>
<li><a href="#" rel="link-blog">rel=link-blog</a></li>
<li><a href="#" rel="linkproducts">rel=linkproducts</a></li>
<li><a href="#" rel="link about">rel=link about</a></li>
<li><a href="#" rel="link-about" title="special">rel=link-about title=special </a></li>
<li><a href="#" rel="link-other" title="special">rel=link-other title=special </a></li>
<li><a href="#" rel="this item available now">rel=this item available now</a></li>
<li><a href="#" rel="product-200-available-now">rel=product-200-available-now</a></li>
<li><a href="#" rel="linkproductavailable300">rel=linkproductavailable300</a>
<li><a href="#" rel="sale-product-400">rel=sale-product-400</a></li>
<li><a href="#" rel="sale">rel=sale</a></li>
<li><a href="#" rel="product-500-discontinued">rel=product-500-discontinued</a></li>
<li><a href="#" rel="product600discontinued">rel=product600discontinued</a></li>
<li><a href="#" rel="discontinued">rel=discontinued</a></li>
</ul>
<script src="script.js"></script>
</body>
</html>
[CSS] DOM Hierarchy Pseudo Classes :first-child :last-child :nth-child (demystified)的更多相关文章
- 【CSS】Intermediate2:Pseudo Classes
1.specify a state or relation to the selector selector:pseudo_class { property: value; } 2.Link 3.Dy ...
- CSS pseudo classes All In One
CSS pseudo classes All In One CSS 伪类 https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes ...
- dom core,html dom,css dom,jquery 中的dom操作
前端开发中为达到某种目的,往往有很多方法:dom core,html dom,jquery; dom core/jquery主要通过函数调用的方式(getAttribute("属性名&quo ...
- [CSS3] Define Form Element States with CSS Form Pseudo Classes
Using just semantic CSS Pseudo-Classes you can help define important states for form elements that e ...
- [CSS3] Identify Interactive HTML Elements with CSS Link Pseudo Classes
The interactive pseudo-classes for links (and buttons) allow us to make sure the user knows what ele ...
- [CSS] The :empty Pseudo Selector Gotchas
The :empty pseudo selector selects empty elements. We can use this to display useful messages instea ...
- Html,Css,Dom,javascript细节总结
最近愈发觉得基础的重要性,细节决定成败,所以希望能够将自己注意到的搜集到的一些关于前端的小细节小知识整理出来,更好的方便自己记忆回顾. 1.在构建网页Html框架时,尽量只给外层标记(即是父标记)定义 ...
- 【CSS】Intermediate7:Pseudo Elements
1.selector:pseudo element{property:value;} 2.first-letter first-line CSS3:: 与pseudo class 区别 old br ...
- html+css+dom补充
补充1:页面布局 一般像京东主页左侧右侧都留有空白,用margin:0 auto居中,一般.w. <!DOCTYPE html> <html lang="en"& ...
随机推荐
- CommonsChunkPlugin的一些总结
CommonsChunkPlugin 官方文档地址 https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin new ...
- jQuery响应式幻灯片插件jquery.glide.js(支持触摸&轻量级)
找到一款好的幻灯片插件不容易,找到一款功能全并且使用很简单的幻灯片更不容易,今天为大家分享一款全能的幻灯片插件glide.js,也是我现在在使用的一款插件. jquery.glide.js是响应和触摸 ...
- 降维(二)----Laplacian Eigenmaps
降维(二)----Laplacian Eigenmaps 降维系列: 降维(一)----说说主成分分析(PCA)的源头 降维(二)----Laplacian Eigenmaps ----------- ...
- Android 常用权限
添加WiFi以及访问网络的权限: <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" ...
- Win7新建ftp快捷方式(原XP网上邻居中客户端图标)
2014-6-2 XP逐渐隐退,新机器一般都是Win7或者Win8了.有很多朋友反映在这两个新系统中找不到类似XP网上邻居中的ftp链接图标.故稍微研究了下,以Win7为例,总结如下. 1.骨灰级 ...
- dump 验证实例恢复的起点和终点
什么时候会产生实例恢复呢?当你数据库服务器异常断电,重启数据库就会发生实例恢复.实例恢复是由数据库自动完成的,无须DBA的干涉.当然这里有个前提条件:数据文件. 在线日志文件.控制文件不得有损坏. 我 ...
- WCF中的由于目标计算机积极拒绝,无法连接
1.第一种情况 百度上找到了这篇文章 http://blog.sina.com.cn/s/blog_6b44b2ba01016j0z.html 讲的是使用了using用完之后就释放了,得到启发,仔细 ...
- Python urllib2写爬虫时候每次request open以后一定要关闭
最近用python urllib2写一个爬虫工具,碰到运行一会程序后就会出现scoket connection peer reset错误.经过多次试验发现原来是在每次request open以后没有及 ...
- Flume FileChannel优化(扩展)实践指南
本文系微博运维数据平台(DIP)在Flume方面的优化扩展经验总结,在使用Flume FileChannel的场景下将吞吐率由10M/s~20M/s提升至80M/s~90M/s,分为四个部分进行介绍: ...
- How many ways
How many ways Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...