Skip to content

Instantly share code, notes, and snippets.

@xgqfrms-GitHub
Last active June 3, 2017 15:15
Show Gist options
  • Save xgqfrms-GitHub/5d022a13292c615d2730e84d909e1aba to your computer and use it in GitHub Desktop.
Save xgqfrms-GitHub/5d022a13292c615d2730e84d909e1aba to your computer and use it in GitHub Desktop.
css-variables
@xgqfrms-GitHub
Copy link
Author

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS3 @import</title>
    <link rel="stylesheet" href="dist/css/index.css">
</head>
<body>
    <div>
        <h1 class="h1">CSS3 @import</h1>
    </div>
    <section>
        <p class="a">a</p>
        <p class="b">b</p>
        <p class="c">c</p>
    </section>
    <footer>
        <span id="xgqfrms_copyright">copyright &copy; xgqfrms 2017</span>
    </footer>
    <!-- js -->
    <script>
        let xcp = document.querySelector('#xgqfrms_copyright');
        xcp.style.color = "#fff";
        xcp.style.background = "#000";
        let x_css = `
            color: red; 
            font-size: 32px;
        `;
        console.log(`%c xcp.style\n`, x_css, xcp.style);
        console.log(`%c typeof(xcp.style)\n`, x_css, typeof(xcp.style));
        // es6-destructuring ES6 解构赋值
        const style = {
            color: 'green',
            fontSize: "32px"
        };
        // xcp.style = style;
        let js = JSON.stringify(style);
        let str = js.replace(/[{}]/g, '');
        // no useful !
        console.log(`%c js \n`, `${js}` , js);
        console.log(`%c str \n`, `${str}` , str);
        console.log(`%c xcp.style & ${JSON.stringify(style)} \n`, `${JSON.stringify(style)}` , xcp.style);
        console.log(`%c xcp.style & ${js} \n`, `${js}` , xcp.style);
        console.log(`%c xcp.style & js \n`, js , xcp.style);
    </script>
</body>
</html>

@xgqfrms-GitHub
Copy link
Author

color console.log() & ES6 Template literals 模板字面量

let x_css = `
    color: red; 
    font-size: 32px;
`;
console.log(`%c xcp.style\n`, x_css, xcp.style);
console.log(`%c xcp.style\n`, `${x_css}`, xcp.style);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment