gpt4 book ai didi

css - 在样式中引用类

转载 作者:太空宇宙 更新时间:2023-11-04 00:09:53 25 4
gpt4 key购买 nike

我有一个作为 anchor 实现的自定义按钮。该按钮有图像和文本。

当按钮有焦点时,我想以不同的方式设置它的样式。具体来说,我想在图像和文本周围绘制一个虚线矩形。我还想根据另一个类另外设置样式。

这是按钮代码:

<a id="searchButton" class="button" href="#">
<span class="icon-search"></span>
Search
</a>

这是带有我的问题的 CSS 代码:

button:focus {
/*How do I make a rectangular dotted line around the button text and icon? /*
/* How do I refer to another class that has additional stylings? */
}

最佳答案

你有“按钮”,但它应该是“.button”,因为你的标签不是按钮,而是你的类。

.button:focus {
outline: #00FF00 dotted thick;
}

关于“如何引用另一个具有额外样式的类?”这个问题,我相信您需要像 SASS、LESS 或其他动态样式表语言这样的库,因为目前不支持这种类型的功能通过原生 CSS。

关于css - 在样式中引用类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13462410/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com