html - CSS - 无序列表 - 类,id 不工作

标签 html css list class

我只想修改一些列表,但我无法使用 class 或 id 来完成它。 这是 MWE:

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    ul#square { list-style: square;}
    ul.square { list-style: square;}
    </style>
    </head>

    <body>
    <ul id="square">
        <li>Coffee</li>
        <li>Tea</li>
        <li>Coca Cola</li>
    </ul>
    <ul style="square">
        <li>Coffee</li>
        <li>Tea</li>
        <li>Coca Cola</li>
    </ul>
    </body>
    </html>

有什么想法吗?

最佳答案

<!DOCTYPE html>
<html>
<head>
<style>
ul#square { list-style: square;}
ul.square { list-style: square;}
</style>
</head>

<body>
<ul id="square">
    <li>Coffee</li>
    <li>Tea</li>
    <li>Coca Cola</li>
</ul>
<ul class="square">
    <li>Coffee</li>
    <li>Tea</li>
    <li>Coca Cola</li>
</ul>
</body>
</html>

JSFiddle 演示: http://jsfiddle.net/bD9nC/

关于html - CSS - 无序列表 - 类,id 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25105152/

相关文章:

php循环重复执行

javascript - jQuery 可排序 - 尝试排序时 div 折叠

list - SwiftUI onDelete 列表与切换

python - 从字典列表中获取新列表

javascript - 如何返回由 Javascript 更改的 onClick 值?

html - Font Awesome 图标未通过 cdn.fontawesome.com 渲染

javascript - HTML5 - 跨浏览器 iframe postMessage - child 到 parent ?

html - 粘性页脚不适用于移动设备

javascript - 我如何使用 CKEditor focusManager 类?

python - 列表追加重置递归函数中的列表