html - 在 li of 2 classes (HTML, CSS) 中选择一个类

标签 html css class html-lists

html:

    <div id="calendar">
        <li class="day">
            <div class="date">4</div>
            <div class="event">
                <div class="event-description">
                    Concert
                </div>
            </div>
        </li>
    </div>

CSS:

#calendar .days li:hover {
    text-decoration: underline;
}

我想给文本加下划线 4,但它只加下划线 Concert.. 当鼠标悬停在 li 上时,如何只在 4 下划线而不在 Concert 下划线??

最佳答案

试试这个

CSS

#calendar li.day:hover .date{text-decoration:underline;}

Working Fiddle

希望这对您有帮助..

关于html - 在 li of 2 classes (HTML, CSS) 中选择一个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45230805/

相关文章:

html - CSS:打破无序列表

javascript - 使用 JavaScript 循环遍历 HTML 中的数据时遇到问题

html - 不同设备的 Bootstrap 段落格式

html - 工具提示 - 标题在 IE 6 中不起作用

html - 居中左对齐的 Bootstrap 列,其中包含卡片

html - 填充权问题

javascript - iPad Safari 上的 CSS3 转换缩放问题

ruby - 我是否必须初始化类的所有成员变量?

c++ - 当我收到 `slicing` 的案例时?

javascript - 如何选择没有特定类的元素