javascript - 如何用组类覆盖元素类
问题描述
我是网络新手,我正在 svg 画布中创建拖放功能,其中我有一组几个 svg 元素。拖动时,我想用组类覆盖元素类。但是元素类具有更高的优先级,并且组的类的应用不会改变子元素的分配属性。那么,如何用组类覆盖元素类呢?!important 在 .drag 没有帮助。
.gBox {
fill:transparent;
stroke-width:0.1
}
.gBox:hover{
stroke:grey;
stroke-dasharray:1,1
}
.rect{
fill:transparent;
stroke:black;
stroke-width:0.5;
}
.hover:hover{
stroke-dasharray:1,1
}
.drag{
stroke:grey;
stroke-dasharray:1,1
}
<g id="myGroup1" class="drag" style="">
<rect id="undefined" x="20" y="10" width="30" height="10" rx="0" ry="0" class="gBox"></rect>
<rect id="myRect1" x="20" y="10" width="10" height="10" rx="1" ry="1" class="rect hover"></rect>
<rect id="myRect2" x="40" y="10" width="10" height="10" rx="1" ry="1" class="rect hover"></rect>
</g>
解决方案
推荐阅读
- vba - 应计时间计算转到 48 小时而不是 24 小时 EXCEL VBA
- unit-testing - Q# 单元测试检查阶段
- java - 堆栈实现 java - LinkedList vs Vector
- python - 下面提到的代码给出了 AttributeError 因为 self.f() 并且当我将 self.f() 重写为 f(self) 错误消失时,为什么会这样?
- flutter - 在这种情况下,有什么方法可以在 initState 中使用 FutureBuilder(future) 吗?
- java - 在线音乐播放器中的音乐仅从服务器播放一次
- java - 无法从 groovy 片段连接 Azure Postgres db
- arrays - 我无法比较 VB.Net 中的两个列表
- c++ - 如何编写一个扩展到负数的阶乘计算器?
- qt - 为什么水平滚动条在 listview qml 上不起作用?