RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
css中:focus-within怎么用

这篇文章主要为大家展示了css中:focus-within怎么用,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带大家一起来研究并学习一下“css中:focus-within怎么用”这篇文章吧。

成都创新互联-专业网站定制、快速模板网站建设、高性价比周村网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式周村网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖周村地区。费用合理售后完善,十余年实体公司更值得信赖。

这里我们用:focus-within玩一把

css中:focus-within怎么用

布局是这样的

外面有一个ctn 可以忽略,就是一个居中固定位置而已

xPassword在没点击之前里面的“suo”这个图是隐藏的

xPassword 同级屁股后的“r6m”此时是显示的

当我们一点击xPassword后同级第一张图‘r6m’隐藏

:focus-within ~ img的 ~ 这个符号是同级屁股后第一个的意思

同时xPassword里面的一张图‘suo’的这个display为显示!这时就成了你输密码我就装作看不见

css中:focus-within怎么用


   
  
    
     
  
             
.ctn {
     position: relative;
    width: 318px;
    margin: 100px auto;
    height: 370px;
    padding: 20px;
    box-sizing: border-box;
    background: #fff;
    z-index: 10;
    box-shadow: 0 0 15px #cfcfcf;
    
}
.ctn h3 {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 30px;
}
.ctn input {
  padding: 10px;
  width: 100%;
  border: 1px solid #e9e9e9;
  border-radius: 2px;
  outline: none;
  box-sizing: border-box;
  font-size: 16px;
}
img {
    position: absolute;
    top: -23%;
    left: 50%;
    width: 80px;
    height: auto;
    transform: translate(-50%, 0);
}

.xPassword img {
  display: none;
  width: 103px;
  height: auto;
  top: -26%;
}

//以上毫无价值,可以忽略,下方两个才是重点



.xPassword:focus-within ~ img {
  display: none;
}

.xPassword:focus-within img {
  display: block;
}

以上就是关于“css中:focus-within怎么用”的内容,如果改文章对你有所帮助并觉得写得不错,劳请分享给你的好友一起学习新知识,若想了解更多相关知识内容,请多多关注创新互联行业资讯频道。


当前文章:css中:focus-within怎么用
本文地址:http://scyingshan.cn/article/jjcidp.html