html - 无法覆盖 css

标签 html css

HTML

<div class="dlrs">
    <div id="listItems">
        <div id="clrCode" class="colorBlock" 
             style="background-image: url("/media/images/orange.png"); background-position: center center; background-repeat: no-          repeat;">
        </div>
        <span>0 pts ( > 20 min)</span>
        <ul id="dlrsList">
            <li id="itmDlrName">Crosstown Auto Centre</li>
            <li id="itmDlrName">Dartmouth Chrysler Jeep Dodge</li>
            <li id="itmDlrName">Grande Prairie Chrysler Jeep Dodge</li>    
        </ul>
    </div>
</div>

CSS

.dlrs {
    //display: inline-block;
    width: 630px;
    margin: 20px 0 20px 20px;
    font-weight: @bldTxt;
    font-size: 14px;

    #listItems {
        width: 200px;
        float: left;
        display: inline-block;

        span {
            position: relative;
            bottom: 16px;
            left: 20px;
        }

        #dlrsList {
            width: 100%;
            text-align: justify;
            /*float: left;
            width: 190px;
            margin-right: 14px;
            margin-bottom: 10px;*/
            #itmDlrName {
                padding: 0px;
                list-style-type:disc;
                position: relative;                
                left: 20px;                
                max-width: 160px;
                font-size: 12px;
            }
        }
    }
}

问题是我试图在我的 li 元素上获取元素符号,发生了什么事是我的文件中有一个 CSS 设置说

ol, ul { list-style-type: none; }

我通过在我的 CSS 中使用上面的 id 增加了特异性,甚至尝试了 !important,但如果我删除 none,我仍然无法覆盖它> FireBug 中的属性并为 li 提供 disc 属性,然后它就可以工作了。

有什么解决办法吗?

最佳答案

这可能是 SASS 或 SCSS 或 LESS,但它不是 CSS。除非通过预处理器运行,否则这将不起作用。

如果你想要直接的 CSS,你不能像那样嵌套你的选择器。

编辑

由于其中有一个变量,我必须假设 OP 有意使用预处理器。假设他的变量 @bldTxt = bold 那么生成的 CSS 是这样的:

.dlrs {
    width: 630px;
    margin: 20px 0 20px 20px;
    font-weight: bold;
    font-size: 14px
}

.dlrs #listItems {
    width: 200px;
    float: left;
    display: inline-block
}

.dlrs #listItems span {
    position: relative;
    bottom: 16px;
    left: 20px
}

.dlrs #listItems #dlrsList {
    width: 100%;
    text-align: justify
}

.dlrs #listItems #dlrsList #itmDlrName {
    padding: 0;
    list-style-type: disc;
    position: relative;
    left: 20px;
    max-width: 160px;
    font-size: 12px
}

假设CSS,list-style-type : disc;只需要移动到.dlrs #listItems #dlrsList,而不是.dlrs #listItems #dlrsList #itemDlrName

关于html - 无法覆盖 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18915752/

相关文章:

jquery - 使用 jQuery 选择 div 内容匹配的子元素并修改附近的其他元素

html - Angular 7 不呈现 Bootstrap 控制

javascript - 这个选项卡 JS 有什么问题?

javascript - 如何用Jplayer播放多个mp3文件?

javascript - 使用 Javascript 淡入/淡出

css - iOS 和 Safari 中 CSS `currentColor` 关键字的问题

javascript - 为其中一个单元格或 td 查找 colSpan header 是 Spans

html - 当我在 Photoshop 中设计图像以作为 CSS 中的标题发布时,分辨率出现问题

html - 使用 CSS 动画加载图像 VS 使用 GIF 图像加载

javascript - 添加新元素后 mCustomScrollbar 不更新