列表

详情


FED10. CSS选择器——伪类选择器

描述

请将html模块中ul列表的第2个li标签和第4个li标签的背景颜色设置成"rgb(255, 0, 0)"。

原站题解

HTML/CSS/JavaScript 解法, 执行用时: 1680ms, 内存消耗: 77852KB, 提交时间: 2022-02-09

{"css":"","js":"","html":"<html>\n    <head>\n        <meta charset=utf-8>\n        <style type=\"text/css\">\n            /*补全代码*/\n            \n        </style>\n    </head>\n    <body>\n        <ul>\n            <li>1</li>\n            <li style=\"background:rgb(255, 0, 0)\">2</li>\n            <li>3</li>\n            <li style=\"background:rgb(255, 0, 0)\">4</li>\n        </ul>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1681ms, 内存消耗: 77884KB, 提交时间: 2022-02-09

{"css":"","js":"","html":"<html>\n    <head>\n        <meta charset=utf-8>\n        <style type=\"text/css\">\n            /*补全代码*/\n            li:nth-child(2n){\n                background-color: rgb(255, 0, 0)\n            }\n        </style>\n    </head>\n    <body>\n        <ul>\n            <li>1</li>\n            <li>2</li>\n            <li>3</li>\n            <li>4</li>\n        </ul>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1682ms, 内存消耗: 77828KB, 提交时间: 2022-02-08

{"css":"","js":"","html":"<html>\n    <head>\n        <meta charset=utf-8>\n        <style type=\"text/css\">\n            /*补全代码*/\n            ul li:nth-child(2),li:nth-child(4){\n                background-color:rgb(255,0,0);\n            }   \n        </style>\n    </head>\n    <body>\n        <ul>\n            <li>1</li>\n            <li>2</li>\n            <li>3</li>\n            <li>4</li>\n        </ul>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1683ms, 内存消耗: 77876KB, 提交时间: 2022-02-09

{"css":"","js":"","html":"<html>\n    <head>\n        <meta charset=utf-8>\n        <style type=\"text/css\">\n            /*补全代码*/\n            \n            .sty{\n               background:rgb(255, 0, 0)\n            } \n        </style>\n    </head>\n    <body>\n        <ul>\n            <li>1</li>\n            <li class=\"sty\">2</li>\n            <li>3</li>\n            <li class=\"sty\">4</li>\n        </ul>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1684ms, 内存消耗: 77844KB, 提交时间: 2022-02-09

{"css":"","js":"","html":"<html>\n    <head>\n        <meta charset=utf-8>\n        <style type=\"text/css\">\n            /*补全代码*/\n            li:nth-child(2),li:nth-child(4){\n                background-color: rgb(255,0,0)\n            }\n        </style>\n    </head>\n    <body>\n        <ul>\n            <li>1</li>\n            <li>2</li>\n            <li>3</li>\n            <li>4</li>\n        </ul>\n    </body>\n</html>","libs":[]}

上一题