Use CSS to write a Pikachu in the form of a code

Source: Internet
Author: User

A while ago on the GitHub of some great God saw him complete a Pikachu in the form of writing code, so the whim took half an hour and finished a work.

This involves the knowledge point is not very complex, is mainly the knowledge of CSS positioning is mostly, and then is the border property how to draw shape.

Online browse URL: CSS painted pikachu (friendly tip: Please computer access, due to the problem of positioning properties, mobile phone display is not very beautiful!)

Then it is a step-by-step piece, how to say, according to the nose, eyes, face, mouth and tongue to draw.

The effect is as follows:

The code is simple, as follows:

HTML code:

<DivID= "Code">        <PreID= "Codeeditor"></Pre>    </Div>    <DivID= "Pikachu">        <Divclass= "Pikachu_container">            <Divclass= "Downlips-container">                <Divclass= "Downlips"></Div>            </Div>            <Divclass= "Nose"></Div>            <Divclass= "Eye Eyeleft"></Div>            <Divclass= "Eye Eyeright"></Div>            <Divclass= "Face Faceleft"></Div>            <Divclass= "Face Faceright"></Div>            <Divclass= "Uplips uplipsleft"></Div>            <Divclass= "Uplips uplipsright"></Div>        </Div>    </Div>

CSS code:

 *{margin:0;padding:0; }#code{width:Calc (48%-10px);Height:100%;Border:1px solid RGB (94, +);position:Absolute; Left:0;Top:0; }#code Pre{width:100%;Height:100%;Display:Inline-block;Overflow:Hidden;overflow-y:Auto; }#pikachu{width:Calc (50%-10px);Margin-left:5px;Margin-right:5px;Height:100%;position:Absolute; Right:0;Top:0;Border:1px solid #302e2e; }#pikachu. Pikachu_container{width:100%;Height:100%;position:Absolute;Top:0; Right:0; }

JS Code:

var code = '/* * First prepare Pikachu background color */.pikachu_container{background: #d3eb4b;}    /* * Draw pikachu nose */.nose{width:0;    height:0;    BORDER:12PX solid;    Border-left-color:transparent;    Border-right-color:transparent;    Border-bottom-color:transparent;    Border-top-color: #000000;    Position:absolute;    left:50%;    top:120px;     border-radius:12px; Margin-left: -9px;}    /* * Draw pikachu eyes */.eye{width:50px;    height:50px;    border-radius:50%;    Background-color: #2e2e2e;    border:2px solid #000000;    Position:absolute;    left:50%; top:80px;}. eyeleft{margin-left: -92px;}. eyeright{margin-left:44px;}    /* * Draw Pikachu Eyeball */.eye:before{content: ';    width:25px;    height:25px;    Position:absolute;    Background-color: #ffffff;    border-radius:50%;    top:2px; left:6px;}    /* * Draw Pikachu's cheek */.face{width:70px;    height:70px;    Background:rgb (230, 62, 40);    border:2px solid #000000;    border-radius:50%;    Position:absolute; top:180px;}. faceleft{    left:20px;}. faceright{right:20px;}    /* * Draw pikachu lips * First draw upper lip */.uplips{width:80px;    height:20px;    border:2px solid #000000;    Background: #d3eb4b;    Position:absolute;    Border-top:none; top:150px;}.    uplipsleft{right:50%;    border-bottom-left-radius:40px 25px;    Border-right:none;   Transform:rotate ( -18deg);}    . uplipsright{left:50%;    Border-left:none;    border-bottom-right-radius:40px 25px; Transform:rotate (18deg);}    /* * Then draw the lip */.downlips-container{position:absolute;    left:50%;    top:160px;    Margin-left: -150px;    height:110px;    width:300px; Overflow:hidden;}.    downlips{width:300px;    height:3500px;    Background-color: #990513;    border-radius:200px/2000px;    Position:absolute;    bottom:0;    border:2px solid #000000; Overflow:hidden;}.    downlips:after{content: ";    width:100px;    height:100px;    Position:absolute;    Background: #fc4a62;    border-radius:50%;    left:50%; Margin-left: -50px; Bottom: -20px;}    `;        function Writecode (str) {var n = 0;            var timer = setinterval (function () {n++;            document.getElementById (' Codeeditor '). InnerHTML = Str.substring (0,n);        document.getElementById (' Styleeditor '). InnerHTML = Str.substring (0,n);        },100);        if (n > Str.length-1) {clearinterval (timer); }} writecode (code);

  

Use CSS to write a Pikachu in the form of a code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.