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. linux - python 安装 Anaconda 环境变量问题请教2. mysql插入文本如果是个sql语句就报错了3. javascript - 使用vue-cli有个报错ERR_INCOMPLETE_CHUNKED_ENCODING4. python中merge后文件莫名变得非常大5. mysql连表排序6. mysql - SQL添加记录的数据来源于同一个表7. mysql sql where id in(25,12,87) 结果集如何用按照 25 12 87排序?8. python3.x - python多线程如何修改数据?9. css3 - 没明白盒子的height随width的变化这段css是怎样实现的?10. html5 - 请问一下写H5的时候 你们都是兼容那些手机

网公网安备