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. Python“文件操作”Excel篇(上)

    大家好,我们今天来一起探索一下用Python怎么操作Excel文件.与word文件的操作库python-docx类似,Python也有专门的库为Excel文件的操作提供支持,这些库包括xlrd.xlw ...

  2. 006-guava 集合-集合工具类-集合扩展工具类

    一.概述 需要实现自己的集合扩展.也许你想要在元素被添加到列表时增加特定的行为,或者你想实现一个Iterable,其底层实际上是遍历数据库查询的结果集 二.使用 2.1.ForwardingList装 ...

  3. django 使用PyMySQL连接mysql

    * 安装pymysql模块 pip install pymysql * settings.py添加下面设置 ## pymysql repalce mysqldb import pymysql pymy ...

  4. 【FreeMarker】FreeMarker使用(三)

    搭建一个 1.FreeMarker取值 <!DOCTYPE html> <html> <head> <meta charset="UTF-8&quo ...

  5. k8s记录-docker私有仓库

    docker pull registry docker run -d -v /data/registry:/var/lib/registry -p 5000:5000 --restart=always ...

  6. 获取Django model中字段名,字段的verbose_name,字段类型

    如下app:ywreport下存在model:Game: class Game(models.Model): name = models.CharField(u'游戏名称',max_length=30 ...

  7. php程序无法记录log情况下可尝试下面方法记录log

    error_reporting(E_ERROR | E_PARSE); function shutdownCallback(){    $arrError = error_get_last(); // ...

  8. linq list select用法注意事项

    下面是我自己做的一个例子 List<CR_CustomerOrder> OrdList = new List<CR_CustomerOrder>(); var b = OrdL ...

  9. 【ARTS】01_45_左耳听风-201900916~201900922

    ARTS: Algrothm: leetcode算法题目 Review: 阅读并且点评一篇英文技术文章 Tip/Techni: 学习一个技术技巧 Share: 分享一篇有观点和思考的技术文章 Algo ...

  10. app--Android 稳定性测试方案

    标准的崩溃日志:Android 应用一般使用 Java 语言开发,在不作特殊处理的情况下,遇到未处理的异常时,会弹框提示“程序遇到异常,即将退出”(有些手机框中提示语不同, 或不弹框).同时会将异常的 ...