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. [原][landcover]全球地表植被样例图片

    图由南水之源提供,感谢    流socket  制作总结 原截图如下:按字母顺序排序 asphalt asphalt_bright asphalt_white brightRockOnly broad ...

  2. 一个Redis实例适合存储不同应用程序的数据吗?

    Redis支持多个数据库,并且每个数据库的数据是隔离的不能共享,并且基于单机才有,如果是集群就没有数据库的概念. Redis是一个字典结构的存储服务器,而实际上一个Redis实例提供了多个用来存储数据 ...

  3. jenkins用户和权限管理

    添加用户 进入管理界面,选择manage users,添加用户 将人和角色绑定 用户和项目绑定 角色管理 可以针对不同的站点对不同的人赋权 添加角色并赋权 将角色赋权给对应的用户 使用新添加的这个用户 ...

  4. js 跳转到 百度指定地址定位点

    js 跳转到 百度指定地址定位点 http://api.map.baidu.com/geocoder?address=北京市海淀区上地信息路9号奎科科技大厦&output=html&s ...

  5. linux非root用户安装5.7.27版本mysql

    先下安装包,到mysql官网https://dev.mysql.com/downloads/mysql/选好安装包版本.操作系统类型(默认是最新版本,点击右边链接Looking for previou ...

  6. Qt编写气体安全管理系统9-数据查询

    一.前言 数据查询模块在整个系统中难度最低,由于Qt对数据库操作的封装堪称完美,所以各种查询都是手到擒来,不费吹灰之力.Qt中内置了sqlite数据库,你可以在数据库插件目录sqldrivers发现q ...

  7. Qt编写气体安全管理系统1-项目框架

    一.前言 说到项目框架,也叫代码框架,其实是非常重要的,随着编程经验的增加,相信每个程序员都会有一个自己的习惯的项目框架,这个东西跟建房子一样,先把架子搭好,然后挨个往里边填充内容,据说牛逼的架构师都 ...

  8. python初级 1 内存和变量

    一.回顾: 1.什么是程序 一堆指令的集合 2.回想一下猜数游戏程序的特征: 1)需要输入(input) 2)会处理输入(process) 3)产生输出(output) 二.程序的一般特征:输入.处理 ...

  9. 单独配置的nginx mysql 重启

    /usr/local/mysql/bin/mysqld_safe /usr/local/nginx/sbin/nginx -s stop /usr/local/nginx/sbin/nginx

  10. 【转】行内元素和inline-block产生的水平空隙bug

    重构工程师们在设计代码时,有喜欢手动删除行内元素之间产生的额外空隙,并通过设置margin或padding来获取想要间距吗?如代码: <div class=“”><span clas ...