Use HTML and CSS to create your own warm man 'Dabai'_HTML/Xhtml_Web page production

WBOY
Release: 2016-05-16 16:36:01
Original
1222 people have browsed it

The final result is like this, isn’t it cute...

PS: You’d better have a certain understanding of HTML and CSS, but it doesn’t matter if you are a novice. It’s okay for a novice to meet “Dabai”!

1. Preparation

Go to the /home/shiyanlou/ directory and create a new blank document:

Named Baymax.html (other names are also acceptable, but the suffix must be .html):

Open with gedit and prepare to edit the code:

2. Writing HTML

Fill in the following code:

XML/HTML CodeCopy content to clipboard
  1. >
  2. <html>
  3.  <head><meta charset="utf-8"><title>Baymaxtitle>head> 
  4. <body>
  5.  <div id="baymax" >
  6.  <div id="head" >
  7.  <div id="eye" >div>
  8.  <div id="eye2" >div>
  9.  <div id="mouth" >div>
  10.  div>
  11.  
  12.  <div id="torso" >
  13.  <div id="heart" >div>
  14.  div>
  15.  <div id="belly" >
  16.  <div id="cover" >div>
  17.  div>
  18.  <div id="left- arm"> 
  19.  <div id="l- bigfinger">div>
  20.  <div id="l- smallfinger">div>
  21.  div>
  22.  
  23.  <div id="right- arm"> 
  24.  <div id="r- bigfinger">div>
  25.  <div id="r- smallfinger">div>
  26.  div>
  27.  
  28.  <div id="left- leg">div>
  29.  <div id="right- leg">div>
  30.  div> 
  31. body>
  32. <html>

3. Add CSS style

We have used HTML to define each element of "Dabai", and now we need to use CSS to draw its style appearance.

Since "Dabai" is white, in order to make it easier to identify, we set the background to a dark color.

Then first the head:

CSS CodeCopy content to clipboard
  1. body {
  2. background: #595959;
  3. }
  4. #baymax{
  5.  /*Set to center*/ 
  6. margin: 0 auto;
  7.  /*Height*/ 
  8. height: 600px;
  9.  /*Hide overflow*/ 
  10. overflow: hidden;
  11. }
  12. #head{
  13.  height: 64px
  14. width: 100px;
  15.  /*Define the shape of the fillet in percentage*/ 
  16. border-radius: 50%;
  17.  /*Background*/ 
  18. background: #fff;
  19. margin: 0 auto;
  20.  margin-bottom: -20px
  21.  /*Set the style of the lower border*/ 
  22. border-bottom: 5px solid #e0e0e0;
  23.  /*Attribute sets the stacking order of elements; Elements with a higher stacking order will always be in front of elements with a lower stacking order*/ 
  24. z-index: 100;
  25.  /*Generate relatively positioned elements*/ 
  26. position: relative;
  27. }

Effect preview:

Hurry up and add eyes and mouth!

CSS CodeCopy content to clipboard
  1. #eye,
  2. #eye2{
  3. width: 11px;
  4. height: 13px;
  5. background: #282828;
  6. border-radius: 50%;
  7. position: relative;
  8. top: 30px;
  9.  left: 27px
  10.  /*Rotate the element*/ 
  11. transform: rotate(8deg);
  12. }
  13. #eye2{
  14.  /*Make it rotationally symmetrical*/ 
  15. transform: rotate(-8deg);
  16. left: 69px; top: 17px;
  17. }
  18. #mouth
  19. width: 38px;
  20.  height: 1.5px
  21. background: #282828;
  22. position: relative;
  23.  left: 34px
  24.  top: 10px
  25. }

A mini "Baymax", the prototype appears:

Next is the torso and abdomen:

CSS CodeCopy content to clipboard
  1. #torso,   
  2. #belly{   
  3.     margin: 0 auto;   
  4.     height200px;   
  5.     width180px;   
  6.     background#fff;   
  7.     border-radius: 47%;   
  8.   
  9.     /*设置边框*/       
  10.     border5px solid #e0e0e0;   
  11.     border-topnone;   
  12.     z-index: 1;   
  13. }   
  14.   
  15. #belly{   
  16.     height300px;   
  17.     width245px;   
  18.     margin-top: -140px;   
  19.     z-index: 5;   
  20. }   
  21.   
  22. #cover{   
  23.     width190px;   
  24.     background#fff;   
  25.     height150px;   
  26.     margin: 0 auto;   
  27.     positionrelative;   
  28.     top: -20px;   
  29.     border-radius: 50%;   
  30. }   
  31.   

赋予「大白」象征生命的心脏:

CSS Code复制内容到剪贴板
  1. #heart
  2. width:25px;
  3. height:25px;
  4. border-radius:50%;
  5. position:relative;
  6. /*Add shadow effect around the border*/
  7. box-shadow:2px 5px 2px #ccc inset;
  8. rightright:-115px;
  9. top:40px;
  10. z-index:111;
  11. border:1px solid #ccc;
  12. }
This is what "Baymax" looks like now:

He doesn’t have any hands or feet yet, he’s so cute... “Baymax” needs warm arms:

CSS Code
Copy content to clipboard
  1. #left-arm,   
  2. #right-arm{   
  3.     height270px;   
  4.     width120px;   
  5.     border-radius: 50%;   
  6.     background#fff;   
  7.     margin: 0 auto;   
  8.     positionrelative;   
  9.     top: -350px;   
  10.     left: -100px;   
  11.     transform: rotate(20deg);   
  12.     z-index: -1;   
  13. }   
  14.   
  15. #right-arm{   
  16.     transform: rotate(-20deg);   
  17.     left100px;   
  18.     top: -620px;   
  19. }   
  20.   

还没有手指头呢:

CSS Code复制内容到剪贴板
  1. #l-bigfinger,   
  2. #r-bigfinger{   
  3.     height50px;   
  4.     width20px;   
  5.     border-radius: 50%;   
  6.     background#fff;   
  7.     positionrelative;   
  8.     top250px;   
  9.     left50px;   
  10.     transform: rotate(-50deg);   
  11. }   
  12.   
  13. #r-bigfinger{   
  14.     left50px;   
  15.     transform: rotate(50deg);   
  16. }   
  17.   
  18. #l-smallfinger,   
  19. #r-smallfinger{   
  20.     height35px;   
  21.     width15px;   
  22.     border-radius: 50%;   
  23.     background#fff;   
  24.     positionrelative;   
  25.     top195px;   
  26.     left66px;   
  27.     transform: rotate(-40deg);   
  28. }   
  29.   
  30. #r-smallfinger{   
  31.     background#fff;   
  32.     transform: rotate(40deg);   
  33.     top195px;   
  34.     left37px;   
  35. }   
  36.   

有点意思了:

迫不及待要给「大白」加上腿了吧:

CSS Code复制内容到剪贴板
  1. #left-leg,   
  2. #right-leg{   
  3.     height170px;   
  4.     width90px;   
  5.     border-radius: 40% 30% 10px 45%;   
  6.     background#fff;   
  7.     positionrelative;   
  8.     top: -640px;   
  9.     left: -45px;   
  10.     transform: rotate(-1deg);   
  11.     z-index: -2;   
  12.     margin: 0 auto;   
  13. }   
  14.   
  15. #right-leg{   
  16.     background#fff;   
  17.     border-radius:30% 40% 45% 10px;   
  18.     margin: 0 auto;   
  19.     top: -810px;   
  20.     left50px;   
  21.     transform: rotate(1deg);   
  22. }   
  23.   

duang~ duang~ duang~ 特技完成!

属于你的暖男大白来到了你的身边,是不是特有安全感哦!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template