css3 - css 选择器如何同时使用属性选择和顺序选择?
问题描述
我需要给 p[class^='xxx'] 的最后一个元素定义样式,可是写 p[class^='xxx']:last-of-type 不起作用,请问要怎么写呢?
问题解答
回答1:<!DOCTYPE html><html> <head><meta charset='UTF-8'><title></title> </head> <style type='text/css'>.d1{ width: 200px; height: 500px; background-color: #0077B0;} </style> <body><p class='d1'> <ul><li class='zz'>li-1</li><li class='zz'>li-2</li><li class='zz'>li-3</li><li class='zz'>li-4</li><li class='zz'>li-5</li> </ul></p><script src='http://libs.baidu.com/jquery/2.0.0/jquery.min.js'></script><script type='text/javascript'> $(function() {$('.d1').click(function() { alert( $('li.zz:last').text() );}) })</script> </body></html>
last last-child 都可以
你很可能需要了解一下last-of-type和last-child的区别
相关文章:
1. 为什么我ping不通我的docker容器呢???2. docker start -a dockername 老是卡住,什么情况?3. docker-machine添加一个已有的docker主机问题4. golang - 用IDE看docker源码时的小问题5. docker镜像push报错6. css - 图片的宽度发生变化而高度却没有相应变?7. html - 竖线怎么实现8. docker - 各位电脑上有多少个容器啊?容器一多,自己都搞混了,咋办呢?9. docker绑定了nginx端口 外部访问不到10. 在windows下安装docker Toolbox 启动Docker Quickstart Terminal 失败!

网公网安备