片段

作者: 隔壁老王z | 来源:发表于2018-11-02 16:28 被阅读0次
  • 黑白和彩色切换:
//给图片添加:
       img{
            height: 100%;
            max-width: 100%;
            transition: all .3s ease;
            /* -webkit-filter: grayscale(100%); */
            filter: grayscale(100%);
            opacity: .66;
        }
        img:hover{
            filter: grayscale(0%);
            opacity: 1;
        }
  • hover一个元素另一个变色:
.el-input-number__increase:hover:not(.is-disabled)~.el-input .el-input__inner:not(.is-disabled){  
        background-color: #fff;
}
  • mouseover和mouseout切换图片:
<span @mouseover="pic = star1_img" @mouseout="pic = star_img">
        <img :src="pic" alt="">
</span>
data () {
      return {
      pic: require('../../static/img/star1.png'),
      star_img: require('../../static/img/star1.png'),
      star1_img:require('../../static/img/star.png')
      }
  }
  • 获取滚动条距离的兼容写法:
var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;

因为当0undefined进行运算,默认返回的是后面一个,window.pageYOffset放在中间不会报错。

  • 对象的解构赋值实际上使得取对象的键值变得更方便:
const { active, count, swipes, deltaX, width } = this;
//再也不用重复使用this.active、this.count等取值,直接用active、count代替
  • 登录成功后返回上次停留页面
    document.referrer指的是打开当前页面的页面,如果用户直接打开了这个页面(不是通过页面跳转,而是通过地址栏或者书签等打开的),则该属性为空字符串。
var prevLink = document.referrer;  
if($.trim(prevLink)==""){  
    location.href = 'www.example.com/index.html';   //回到首页
}else{  
    if(prevLink.indexOf('www.example.com')==-1){    //来自其它站点  
        location.href = 'www.example.com/index.html';  
    }  
    if(prevLink.indexOf('register.html')!=-1){      //来自注册页面  
        location.href = 'www.example.com/index.html';  
    }  
    location.href = prevLink;  //其他情况
}  
  • git merge的冲突判定机制如下:先寻找两个commit的公共祖先,比较同一个文件对于公共祖先的差异,然后合并这两组差异。如果双方同时修改了一处地方且修改内容不同,就判定为合并冲突,依次输出双方修改的内容。
  • 实现文字溢出时使用省略号表示:
//包裹文字的盒子设置css:
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  • 渐变边框
<div class="box first"></div>
<div class="box second"></div>
<div class="box third"></div>
.box {
  margin: 80px 30px;
  width: 200px;
  height: 200px;
  position: relative;
  background: #fff;
  float: left;
}
.box:before {
      content: '';
      z-index: -1;
      position: absolute;
      width: 220px;
      height: 220px;
      top: -10px;
      left: -10px;
}

.first:before {
  background-image: linear-gradient(90deg, yellow, gold);
}
.second:before {
  background-image: linear-gradient(0deg, orange, red);
}
.third:before {
        background-image: repeating-linear-gradient(-45deg,#cc2a2d,#cc2a2d 30px,#f2f2f2 30px,#f2f2f2 40px,#0e71bb 40px,#0e71bb 70px,#f2f2f2 70px,#f2f2f2 80px);
}
image.png

相关文章

  • 反焦虑思维

    片段一 片段二 片段三 片段四

  • 片段(片段练笔)

    姜一讲话的时候,像是有雷电经过,下一秒子弹击中的时候,逐步的扩大,直到扩大伤害范围。 急切地说话,空气中凝滞的...

  • 商品放大镜效果

    html片段 js片段 css片段

  • 第三次作业

    R片段 I片段 A1片段 A2便签 R片段 I便签 A1便签 R片段 I便签 A1便签 A2片段 R片段 I便签 ...

  • shell-01

    shell片段1 shell片段2 shell片段3

  • 记忆片段  片段记忆

    1,相信在一个陌生的环境里,你会对过去的一些事渐渐隐没心底。人总是要活着,活着的原因很多,至少为了父母和自己。出去...

  • 8、RIA特训第四周

    片段一、《谈话的力量》1 片段二、《谈话的力量》2 片段三、《谈话的力量》3 片段四、《谈话的力量》4 片段五、《...

  • #知识体系精深营#+5月份+第4次作业+第23组+九妹妈

    片段 片段接上面

  • vscode 代码片段设置

    文件-首选项-用户片段 选择新建代码片段 打印代码片段

  • 片段

    五脏六腑 熊熊燃烧的火焰 点燃一根烟 狠狠吸上一口再一口 不间断 加速燃烧 尽情燃烧 最终手指轻轻一弹 曾经攥紧我...

网友评论

      本文标题:片段

      本文链接:https://www.haomeiwen.com/subject/ztecxqtx.html