首页 \ 问答 \ 如何确定CSS切换输入的“切换”状态?(How to determine the 'toggle' status of a CSS toggle input?)

如何确定CSS切换输入的“切换”状态?(How to determine the 'toggle' status of a CSS toggle input?)

我想实现一个基于CSS的切换/切换输入。 我发现以下链接的例子非常简单,根本不使用JavaScript。 问题在于它缺少关于如何确定'切换'状态的解释

http://www.w3schools.com/howto/howto_css_switch.asp

这是完整的参考代码:

/* The switch - the box around the slider */
.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

/* Hide default HTML checkbox */
.switch input {display:none;}

/* The slider */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}
<!-- Rounded switch -->
<label class="switch">
  <input type="checkbox">
  <div class="slider"></div>
</label>


I would like to implement a CSS-based toggle/switch input. I found the example of the following link which is really easy and not using javascript at all. The problem is that it's lacking the explanation of how to determine the 'toggle' status

http://www.w3schools.com/howto/howto_css_switch.asp

This is the full code for reference:

/* The switch - the box around the slider */
.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

/* Hide default HTML checkbox */
.switch input {display:none;}

/* The slider */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}
<!-- Rounded switch -->
<label class="switch">
  <input type="checkbox">
  <div class="slider"></div>
</label>


原文:https://stackoverflow.com/questions/40317740
更新时间:2023-08-23 06:08

最满意答案

在rs中获取结果集后尝试这个:

   PreparedStatement st = (PreparedStatement) con.prepareStatement("insert into temp values(?)");
    i=0;
   while(rs.next())
    {
      st.setString(1,anArray[i]);
      st.executeUpdate();
      i++;
    }

try this after getting resultset in rs:

   PreparedStatement st = (PreparedStatement) con.prepareStatement("insert into temp values(?)");
    i=0;
   while(rs.next())
    {
      st.setString(1,anArray[i]);
      st.executeUpdate();
      i++;
    }

相关问答

更多
  • 我认为使用rawQuery是一个坏习惯,尽量避免这种情况(除极端情况外) 请尝试以下方法来解决您的问题,希望这会对您有所帮助: public ArrayList getAllStringValues() { ArrayList yourStringValues = new ArrayList(); Cursor result = db.query(true, YOUR_TABLE, new String[] { YOUR ...
  • 您可以随时序列化数组并将其存储在数据库中。 PHP序列化 然后,您可以在需要时取消对数组进行序列化。 You can always serialize the array and store that in the database. PHP Serialize You can then unserialize the array when needed.
  • 正确的方法是使用多个表并在查询中JOIN它们。 例如: CREATE TABLE person ( `id` INT NOT NULL PRIMARY KEY, `name` VARCHAR(50) ); CREATE TABLE fruits ( `fruit_name` VARCHAR(20) NOT NULL PRIMARY KEY, `color` VARCHAR(20), `price` INT ); CREATE TABLE person_fruit ( `person_id` INT NO ...
  • 您可以向表中添加“index”或“id”列或使用此代码 $index = 0; $q = mysql_query("SELECT Indicators FROM geographic_main"); while(list($indicator) = @mysql_fetch_row($q)) { mysql_query("UPDATE geographic_main SET Weight='".$weights[$index++]."' WHERE Indicators='$indicator'"); ...
  • 首先,你真的不想那样做。 RDBMS中的列是原子的,因为它包含一条且只有一条信息。 尝试在列中存储多个数据是违反第一范式的。 如果您绝对必须这样做,那么您需要将数据转换为可以存储为单个数据项(通常是字符串)的表单。 您可以使用PHP的serialize()机制,XML解析(如果数据恰好是文档树),json_encode()等。 但是,您如何有效地查询这些数据? 答案是你不能。 此外,如果其他人在以后接管你的项目,你真的会惹恼他们,因为数据库中的序列化数据是可怕的。 我知道因为我继承了这样的项目。 我提到你真 ...
  • 您可以使用ndarray.dumps()将其pickle为字符串然后将其写入BLOB字段? 使用numpy.loads()恢复它 You could use ndarray.dumps() to pickle it to a string then write it to a BLOB field? Recover it using numpy.loads()
  • 在rs中获取结果集后尝试这个: PreparedStatement st = (PreparedStatement) con.prepareStatement("insert into temp values(?)"); i=0; while(rs.next()) { st.setString(1,anArray[i]); st.executeUpdate(); i++; } try this after getting result ...
  • 如果要将byte[]转换为sql类型Blob ,可以执行以下操作: @Lob(type = LobType.BLOB) 要么 @Type(type = "org.hibernate.type.BlobType") @Lob 希望能帮助到你 Well, I have tried your suggestions @Ernusc. The first one: @Lob(type = LobType.BLOB) private byte[] blobImg; it is no compiling for ...
  • 我认为在添加列时不需要指定“COLUMN”关键字。 以下是添加列的正确语法 ALTER TABLE table_name ADD column_name datatype 所以你的语句创建行应该是这样的, PreparedStatement pst=con.prepareStatement("alter table distable add ? varchar(50)"); 更新 :刚想通了吗? 参数仅适用于数据,不适用于列名称。 如果您需要以这种方式生成列名称,则可以使用字符串连接。 例如, "al ...

相关文章

更多

最新问答

更多
  • python的访问器方法有哪些
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。
  • 响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
  • 在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
  • NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
  • 元素上的盒子阴影行为(box-shadow behaviour on elements)
  • Laravel检查是否存在记录(Laravel Checking If a Record Exists)
  • 设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
  • 想学Linux 运维 深圳有哪个培训机构好一点
  • 为什么有时不需要在lambda中捕获一个常量变量?(Why is a const variable sometimes not required to be captured in a lambda?)
  • 在Framework 3.5中使用服务器标签<%=%>设置Visible属性(Set Visible property with server tag <%= %> in Framework 3.5)
  • AdoNetAppender中的log4net连接类型无效(log4net connection type invalid in AdoNetAppender)
  • 错误:发送后无法设置标题。(Error: Can't set headers after they are sent. authentication system)
  • 等待EC2实例重启(Wait for an EC2 instance to reboot)
  • 如何在红宝石中使用正则表达式?(How to do this in regex in ruby?)
  • 使用鼠标在OpenGL GLUT中绘制多边形(Draw a polygon in OpenGL GLUT with mouse)
  • 江民杀毒软件的KSysnon.sys模块是什么东西?
  • 处理器在传递到add_xpath()或add_value()时调用了什么顺序?(What order are processors called when passed into add_xpath() or add_value()?)
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • SQL查询,其中字段不包含$ x(SQL Query Where Field DOES NOT Contain $x)
  • PerSession与PerCall(PerSession vs. PerCall)
  • C#:有两个构造函数的对象:如何限制哪些属性设置在一起?(C#: Object having two constructors: how to limit which properties are set together?)
  • 平衡一个精灵(Balancing a sprite)
  • n2cms Asp.net在“文件”菜单上给出错误(文件管理器)(n2cms Asp.net give error on Files menu (File Manager))
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的