input 和label配合的妙用

1:作为文字隐藏与否的开关;

如下代码:对div里面所包含的文字较多,一开始只展示小部分,当用户点击按钮时,进行全部内容的展示(按钮是以向下隐藏箭头的图片)

html代码如下

   <input type="checkbox" id="A1" >
    <div>
 lestias assumenda nesciunt maiores minus molestiae exercitationem, dolores odit similique. Quidem odit distinctio optio totam eaque reiciendis expedita, voluptatem impedit iste placeat voluptate eius fugit vero, ut minus laudantium ullam debitis dolor? Possimus inventore sit molestiae distinctio. Dolore perspiciatis commodi maiores eius incidunt aut quisquam tenetur neque. Magni voluptatibus omnis tempore quas quos! Quisquam, molestias. Natus, illo culpa tempore enim praesentium corrupti ipsum! Sed eveniet voluptate, minus tempora illum deleniti laudantium facere enim nesciunt, aliquid temporibus pariatur qui. Totam autem consequatur officiis libero magni sit asperiores magnam ipsum.
    </div>  
    <!-- <input type="checkbox" id="A1" > -->
    <label for="A1">
        <img src="向下箭头按钮.jpg" alt="">
    </label>
 
 
css代码如下:
div{
    width: 500px;
    height: 100px;
    margin: auto;
    border: 1px solid red;
    overflow: hidden;
}
 
 
input{
    display: none;
}
                               // 当input被选中的时候,img 按钮转180,向上
                                  input:checked~label>img{
                                         transform: rotate(180deg);
                                 }
// 当input被选中的时候,div内容显示(选择器;只能是兄弟,而不能是弟兄,也就是说可以选中前面的标签+后面的标签;不能选择后面的标签+前面的标签)
input:checked+div{
    height: auto;
}
 
2:点击效果展示,当一个图片被点击后,图片就被换掉(以此来提醒用户点击成功,增加用户体验)
HTML代码如下(p元素用来插入背景图片,作为用户点击的按钮):
<input type="checkbox" id="B2">
<label for="B2">
        <p></p>
</label>
 
CSS代码如下:
p{
   margin: 0;
   padding:0;
   width: 52px;
   height: 52px;
   background-image: url("点击前图片按钮.jpg")
}
#B2:checked+label>p{
    background-image: url("点击后图片按钮.jpg")
 }

input 被checked时和label配合的妙用的更多相关文章

  1. input是否checked与使用jquery的attr或prop方法无关

    最近在项目中有这样一个需求,用户在下单时可以选择优惠券,也可取消选择,并且可以多次选择,取消. 这是一个典型的input标签checked功能,博主使用radio元素实现此需求,但是优惠券只能选中,不 ...

  2. jquery attr方法和prop方法获取input的checked属性问题

    jquery attr方法和prop方法获取input的checked属性问题   问题:经常使用jQuery插件的attr方法获取checked属性值,获取的值的大小为未定义,此时可以用prop方法 ...

  3. java中 label 配合 break continue 使用方法

    转 https://www.jianshu.com/p/7954b61bc6ee java中 label 配合 break continue 使用的其实是比较少的. 这种做法在业务代码中比较少见. 在 ...

  4. HTML input="file" 浏览时只显示指定文件类型 xls、xlsx、csv

    html input="file" 浏览时只显示指定文件类型 xls.xlsx.csv <input id="fileSelect" type=" ...

  5. faster rcnn test demo ---repaired for video input and save the image, label, score et al. into .mat format

    faster rcnn test demo ---repaired for video input and save the image, label, score et al. into .mat ...

  6. Chrome浏览器,处理input自动填充时带黄色背景色

    /*Chrome浏览器打开网页,input自动赋值时,会带上屎黄色的背景色,下面是通过延长增加自动填充背景色的方式, 让用户感受不到样式的变化*/ input:-webkit-autofill, in ...

  7. input type="number"时,maxlength不起作用怎么解决

    最近小颖在做公司的angular项目时,发现当input type="number"时,maxlength不起作用,百度了下解决方式,顺便记录下,以便后期查看嘻嘻 <inpu ...

  8. react中IOS手机里面两个input同时存在时,聚焦focus失效解决办法

    最近在做webapp搜索功能时,用到两个input同时存在时,轻点input聚焦时,ios手机软键盘弹起又失效,一直在寻找合理的解决办法,现在最简单的总结回顾: <一>bug显示 < ...

  9. 阻止移动端input按钮聚焦时唤起软键盘的方法

    一.设置input为readonly 二.使用JS代码,在input按钮fous时就让其blur

随机推荐

  1. k8s之磁盘挂载持久化

  2. 蒙特卡洛树搜索算法 —— github上的implement的原代码

    首先在网上看到了关于蒙特卡洛搜索算法的介绍,如下: https://www.cnblogs.com/steven-yang/p/5993205.html 并从中发现了一个在GitHub上impleme ...

  3. Laya的位图文字

    参考: Laya文本 测试版本:Laya 2.1.1.1 大部分游戏都会用到位图文字,例如dnf的伤害数字. 白鹭的位图文字是美术提供0-9十张单张图片,由TextureMerger导出fnt+jso ...

  4. 转 zabbix 优化方法 以及 后台数据库查询方法 两则

    ############sample 1 https://blog.51cto.com/sfzhang88/1558254 如何从Zabbix数据库中获取监控数据 sfzhang关注6人评论40627 ...

  5. Delphi : TStringList的Find,IndexOf和Sort

    关键:Find要事先Sort排序,Indexof不用排序. TStringList内部查找相关的数据.待调试代码时才知道痛苦,浪费无数时间后,只得一步步跟踪,才发 现Find方法返回的Index总是错 ...

  6. SpringBoot学习笔记:自定义拦截器

    SpringBoot学习笔记:自定义拦截器 快速开始 拦截器类似于过滤器,但是拦截器提供更精细的的控制能力,它可以在一个请求过程中的两个节点进行拦截: 在请求发送到Controller之前 在响应发送 ...

  7. 【计算机视觉】行为识别(action recognition)相关资料

    ================华丽分割线=================这部分来自知乎==================== 链接:http://www.zhihu.com/question/3 ...

  8. 知识点-Spark小节

    Spark处理字符串日期的max和min的方式Spark处理数据存储到Hive的方式Spark处理新增列的方式map和udf.functionsSpark处理行转列pivot的使用Python 3.5 ...

  9. 使用video.js 7在html中播放rtmp视频流

    1.背景 最近要做摄像头视频的展示,不想使用硬件方的专用插件,所以计划视频推送到SRS服务器,浏览器再通过rtmp协议显示,类似于直播. 经查询,了解到可以用ckplayer(有许可条款)和video ...

  10. Python 绘图库Matplotlib入门教程

    0 简单介绍 Matplotlib是一个Python语言的2D绘图库,它支持各种平台,并且功能强大,能够轻易绘制出各种专业的图像. 1 安装 pip install matplotlib 2 入门代码 ...