Git Product home page Git Product logo

purecss's Introduction

Hi there 👋

Anurag's GitHub stats

purecss's People

Contributors

palmerye avatar

Watchers

 avatar  avatar

purecss's Issues

文字金属质感

主要用到的是background-clip这个属性,这个效果是自己YY的,其实还是有点缺陷,比如...

16619dd33852f081.png

<h1>CaptureColor</h1>

h1 {
    font-size: 15rem;
    line-height: 21rem;
    font-weight: bold;
    text-shadow: 0 -1px 0 rgba(165, 153, 153, 0), 0 1px 10px rgba(0, 0, 0, .6), 0 6px 1px rgba(0, 0, 0, .1), 0 0 5px rgba(0, 0, 0, .2), 0 1px 3px rgba(0, 0, 0, .3), 0 3px 5px rgba(0, 0, 0, .2), 0 7px 10px rgba(0, 0, 0, .25), 0 15px 10px rgba(0, 0, 0, .2), 0 25px 15px rgba(0, 0, 0, .15);
    position: relative;
    overflow: hidden;
    background-image: -webkit-linear-gradient(135deg, #000, #000 5%, #000 48.5%, rgb(39, 38, 38) 49%, #fff 50%, rgb(39, 38, 38) 51%, #000 51.5%, #000 98%, #000);
    -webkit-text-fill-color: transparent;  // 文字填充色为透明
    -webkit-text-stroke: .2px rgba(247, 240, 240, 0.164);
    -webkit-background-clip: text; // 背景被裁剪为文字的前景色(只有chrome支持)
    -webkit-background-size: 400% 100%; // 放大背景区域,使光线进入并消失
    -webkit-animation: masked-animation 3s infinite ease-out forwards;
    @-webkit-keyframes masked-animation {
        0%  { background-position: 0 0;}
        100% { background-position: -100% 0;}
    }
}

background-clip

MDN文档中,介绍到这个属性作用,设置元素的背景(背景图片或颜色)是否延伸到边框下面。

  • border-box:背景延伸到边框外沿(但是在边框之下)。
  • padding-box:边框下面没有背景,即背景延伸到内边距外沿。
  • content-box:背景裁剪到内容区 (content-box) 外沿。
  • text:背景被裁剪为文字的前景色(只有chrome支持)。

箭头形变效果

这个创意效果是在uimovement看到的,有时候不得不佩服一些优秀的设计师的创意。仿照设计师的效果图自己琢磨了下,在箭头转化为方块的动画效果上其实还有点欠缺,没有明显的从箭头慢慢形变成方块。

第一张为原图,第二张为实现的效果图

1661a022478fe941.png
16619f49c2afccd5.png

<span>Let's Go!</span>

span {
    display: inline-block;
    margin: 0 3rem;
    padding: 0 1rem;
    width: 15rem;
    height: 5rem;
    font-size: 3rem;
    line-height: 5rem;
    text-align: center;
    color: #fff;
    font-weight: bold;
    position: relative;
    transition: all .3s;

    &::after {
        content: '→';
        position: absolute;
        right: -1rem;
        transition: all .1s;
    }

    &::before {
        content: ' ';
        display: inline-block;
        width: 2rem;
        height: 0.2rem;
        position: absolute;
        top: 2.35rem;
        right: -1rem;
        background: #fff;
        z-index: -1;
        opacity: 0;
        transition: all .2s ease-in;
    }

    &:hover {
        cursor: pointer;
        margin: 0;
        color: #000;

        &::before {
            transform: translateX(-2rem) scale(7.5, 25);
            transform-origin: 100% 40%;
            opacity: 1;
        }

        &::after {
            opacity: 0;
        }
    }
}

实现思路

这里主要用两个伪类来实现,hover后的背景为before,箭头为afterbeforehover前作为一根细线藏在箭头下,hover的时候,after箭头透明度过渡降为0,before这根线可以transform形变缩放为元素的背景方块。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.