- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
这是我的:
具有多行的 SVG。这些有类型作为 CSS 类。例如:.pen1 .pen2 .pen3 .pen4。和.special
每一行都有前四行之一,并且可以有 .spcial!还有一些.special only lines.
可以使用按钮激活和停用这些类中的每一个。
我的问题是:
(A 行有 .pen1,B 行有 .pen1 .special,C 行有 .pen2,D 行有 .pen2 .special)
程序如下:
但我需要两者都在 2) 中消失,然后两者都应在 3) 中重新出现。
我目前的解决方案是,如果我按下 .pen1 的按钮,我会设置一个标志,表明它已被按下,并在我按下 .special 时测试这个标志 --> 这有效,但前提是只有一个类有自己的和.特殊类
这是我现在的代码:
用于特殊切换:
if (this._pen1|| this._pen2|| this.pen3|| this.pen4 ){
if (this.special) {
if (this.pen1) {
[...].find('svg .' + _PENSTYLES.special).not('.' + _PENSTYLES.pen1).hide(0);
}
if (this.pen2) {
[...].find('svg .' + _PENSTYLES.special).not('.' + _PENSTYLES.pen2).hide(0);
}
if (this.pen3) {
[...].find('svg .' + _PENSTYLES.special).not('.' + _PENSTYLES.pen3).hide(0);
}
if (this.pen4) {
[...].find('svg .' + _PENSTYLES.special).not('.' + _PENSTYLES.pen4).hide(0);
}
} else {
if (this.pen1) {
[...].find('svg .' + _PENSTYLES.special).not('.' + _PENSTYLES.pen1).show(0);
}
if (this.pen2) {
[...].find('svg .' + _PENSTYLES.special).not('.' + _PENSTYLES.pen2).show(0);
}
if (this.pen3) {
[...].find('svg .' + _PENSTYLES.special).not('.' + _PENSTYLES.pen3).show(0);
}
if (this.pen4) {
[...].find('svg .' + _PENSTYLES.special).not('.' + _PENSTYLES.pen4).show(0);
}
}
} else {
[...].find('svg .' + _PENSTYLES.special).toggle(0);
}
this.special= !this.special;
pen1-4 切换:
if (this.special) {
[...].find('svg .' + _PENSTYLES.pen1).not('.' + _PENSTYLES.special).toggle(0);
} else {
[...].find('svg .' + _PENSTYLES.pen1).toggle(0);
}
this.pen1= !this.pen1;
我希望有人能帮助我解决多行问题。因为现在他们 pen2 覆盖 pen1 并显示/隐藏其他人排除的所有内容。
最佳答案
以下是我认为您正在寻找的入门内容的简化。运行该代码段以查看其工作情况。
var hidden = [];
function toggle(classname) {
if (hidden.indexOf(classname) > -1) {
hidden.splice(hidden.indexOf(classname), 1);
getElements(classname).forEach(function(ele) {
ele.classList.remove("hidden");
});
} else {
hidden.push(classname);
}
hidden.forEach(function(hide) {
getElements(hide).forEach(function(ele) {
ele.classList.add("hidden")
});
})
}
function getElements(classname) {
return Array.from(document.getElementsByClassName(classname));
}
html {
font-family: sans-serif;
}
.root {
display: flex;
}
.root>div {
flex: 0 0 80px;
}
button{
width: 70px;
}
svg line {
stroke-width: 2;
}
.special {
stroke: red;
stroke-dasharray: 5;
}
.pen1 {
stroke: blue;
}
.pen2 {
stroke: green;
}
.pen3 {
stroke: goldenrod;
}
.pen4 {
stroke: DarkOrchid;
}
text {
font-size: 14px;
}
.hidden {
display: none;
}
<div class="root">
<div>
<button onclick="toggle('pen1')">.pen1</button>
<button onclick="toggle('pen2')">.pen2</button>
<button onclick="toggle('pen3')">.pen3</button>
<button onclick="toggle('pen4')">.pen4</button>
<button onclick="toggle('special')">.special</button>
</div>
<svg width="400" height="200" viewBox="0 0 400 200">
<rect width="400" height="200" fill="#efefef" />
<line class="pen1" y1="20" y2="20" x1="0" x2="300" />
<line class="pen2" y1="40" y2="40" x1="0" x2="300" />
<line class="pen3" y1="60" y2="60" x1="0" x2="300" />
<line class="pen4" y1="80" y2="80" x1="0" x2="300" />
<line class="pen1 special" y1="100" y2="100" x1="0" x2="300" />
<line class="pen2 special" y1="120" y2="120" x1="0" x2="300" />
<line class="pen3 special" y1="140" y2="140" x1="0" x2="300" />
<line class="pen4 special" y1="160" y2="160" x1="0" x2="300" />
<line class="special" y1="180" y2="180" x1="0" x2="300" />
<text x="310" y="20" alignment-baseline="middle">.pen1</text>
<text x="310" y="40" alignment-baseline="middle">.pen2</text>
<text x="310" y="60" alignment-baseline="middle">.pen3</text>
<text x="310" y="80" alignment-baseline="middle">.pen4</text>
<text x="310" y="100" alignment-baseline="middle">.pen1 .special</text>
<text x="310" y="120" alignment-baseline="middle">.pen2 .special</text>
<text x="310" y="140" alignment-baseline="middle">.pen3 .special</text>
<text x="310" y="160" alignment-baseline="middle">.pen4 .special</text>
<text x="310" y="180" alignment-baseline="middle">.special</text>
</svg>
</div>
关于javascript - 切换具有多个值的选择器 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52990715/
这是代码片段。 请说出这种用小内存存储大数据的算法是什么。 public static void main(String[] args) { long longValue = 21474836
所以我使用 imap 从 gmail 和 outlook 接收电子邮件。 Gmail 像这样编码 =?UTF-8?B?UmU6IM69zq3OvyDOtc68zrHOuc67IG5ldyBlbWFpb
很久以前就学会了 C 代码;想用 Scheme 尝试一些新的和不同的东西。我正在尝试制作一个接受两个参数并返回两者中较大者的过程,例如 (define (larger x y) (if (> x
Azure 恢复服务保管库有两个备份配置选项 - LRS 与 GRS 这是一个有关 Azure 恢复服务保管库的问题。 当其驻留区域发生故障时,如何处理启用异地冗余的恢复服务保管库?如果未为恢复服务启
说,我有以下实体: @Entity public class A { @Id @GeneratedValue private Long id; @Embedded private
我有下一个问题。 我有下一个标准: criteria.add(Restrictions.in("entity.otherEntity", getOtherEntitiesList())); 如果我的
如果这是任何类型的重复,我会提前申请,但我找不到任何可以解决我的具体问题的内容。 这是我的程序: import java.util.Random; public class CarnivalGame{
我目前正在使用golang创建一个聚合管道,在其中使用“$ or”运算符查询文档。 结果是一堆需要分组的未分组文档,这样我就可以进入下一阶段,找到两个数据集之间的交集。 然后将其用于在单独的集合中进行
是否可以在正则表达式中创建 OR 条件。 我正在尝试查找包含此类模式的文件名列表的匹配项 第一个案例 xxxxx-hello.file 或者案例二 xxxx-hello-unasigned.file
该程序只是在用户输入行数时创建菱形的形状,因此它有 6 个 for 循环; 3 个循环创建第一个三角形,3 个循环创建另一个三角形,通过这 2 个三角形和 6 个循环,我们得到了一个菱形,这是整个程序
我有一个像这样的查询字符串 www.google.com?Department=Education & Finance&Department=Health 我有这些 li 标签,它们的查询字符串是这样
我有一个带有静态构造函数的类,我用它来读取 app.config 值。如何使用不同的配置值对类进行单元测试。我正在考虑在不同的应用程序域中运行每个测试,这样我就可以为每个测试执行静态构造函数 - 但我
我正在寻找一个可以容纳多个键的容器,如果我为其中一个键值输入保留值(例如 0),它会被视为“或”搜索。 map, int > myContainer; myContainer.insert(make_
我正在为 Web 应用程序创建数据库,并正在寻找一些建议来对可能具有多种类型的单个实体进行建模,每种类型具有不同的属性。 作为示例,假设我想为“数据源”对象创建一个关系模型。所有数据源都会有一些共享属
(1) =>CREATE TABLE T1(id BIGSERIAL PRIMARY KEY, name TEXT); CREATE TABLE (2) =>INSERT INTO T1 (name)
我不确定在使用别名时如何解决不明确的列引用。 假设有两个表,a 和 b,它们都有一个 name 列。如果我加入这两个表并为结果添加别名,我不知道如何为这两个表引用 name 列。我已经尝试了一些变体,
我的查询是: select * from table where id IN (1,5,4,3,2) 我想要的与这个顺序完全相同,不是从1...5,而是从1,5,4,3,2。我怎样才能做到这一点? 最
我正在使用 C# 代码执行动态生成的 MySQL 查询。抛出异常: CREATE TABLE dump ("@employee_OID" VARCHAR(50)); "{"You have an er
我有日期 2016-03-30T23:59:59.000000+0000。我可以知道它的格式是什么吗?因为如果我使用 yyyy-MM-dd'T'HH:mm:ss.SSS,它会抛出异常 最佳答案 Sim
我有一个示例模式,它的 SQL Fiddle 如下: http://sqlfiddle.com/#!2/6816b/2 这个 fiddle 只是根据 where 子句中的条件查询示例数据库,如下所示:
我是一名优秀的程序员,十分优秀!