【问题标题】:How to style a tag for current div with css?如何使用 css 为当前 div 设置标签样式?
【发布时间】:2015-06-02 16:42:15
【问题描述】:

我的 div:

 <div id="dialog" class="window">
        <table class="modalWindow" border="1">
            <tr>
                <td colspan="2"><input type="text" id="feedName" value="" /></td>
            </tr>
            <tr>
                <td><input type="submit" id="renameFeed" value="Submit"></td>
                <td><a href="#" class="close">Close it</a></td>
            </tr>
        </table>
    </div>

需要使用 css 为当前 div 设置 &lt;a href="#" class="close"&gt;Close it&lt;/a&gt; 样式。 怎么做?

【问题讨论】:

  • #dialog a { ... } 应该可以解决问题。

标签: html css tags styling


【解决方案1】:

这将只设置带有 close 类的 a 元素(它们是#dialog 的后代),这就是您想要的:对关闭文本的唯一控制,而不是所有链接文本

#dialog a.close {
   /*insert css here*/
}
#dialog a.close:hover {
   /*insert cool hover css here*/
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-14
    • 1970-01-01
    • 1970-01-01
    • 2019-05-16
    • 1970-01-01
    • 1970-01-01
    • 2020-12-18
    • 2013-12-04
    相关资源
    最近更新 更多