Use Div+css to make a cube

Source: Internet
Author: User

    <style>. Cube{width:200px;Height:200px;margin:100px Auto;position:relative;            /*perspective:1000px;*/Transform:Rotatex (30deg) Rotatey (30deg);Transform-style:preserve-3d;        }. Front,. Back,. Top,. Bottom,.{width:200px;Height:200px;font-family:"Microsoft Yahei";Line-height:200px;text-align:Center;position:Absolute;Top:0; Left:0;Opacity:0.5;        }. Front{Background-color:#008000;Transform:Translatez (100px);        }. Back{Background-color:#ffff00;Transform:Translatez ( -100px);        }. Top{Background-color:#ff0000;Transform:Rotatex (90deg) Translatez (100px);        }. Bottom{Background-color:#ffa500;Transform:Rotatex (90deg) Translatez ( -100px);        }. Left{Background-color:#0000ff;Transform:Rotatey (90deg) Translatez ( -100px);        }. Right{Background-color:#ffc0cb;Transform:Rotatey (90deg) Translatez (100px);        }    </style>    <Divclass= "Cube">        <Divclass= "Front">Front</Div>        <Divclass= "Back">Back</Div>        <Divclass= "Top">Top</Div>        <Divclass= "Bottom">Bottom</Div>        <Divclass= "Left">Left</Div>        <Divclass= "Right">Right</Div>    </Div>

Thought: Mr. 6 Square, then the 6 squares in accordance with the order of the left and right to deflect half of their length, and then the CSS code to the 6 squares set a whole, namely the cube. Then rotate the cube to a certain angle, then set the transparency (which can be seen from the front) and visually look more realistic.

Frontbacktopbottomleftright

Use Div+css to make a cube

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.