Css畫聖誕樹

來源:互聯網
上載者:User

標籤:印象   auto   todo   http   浮動   img   padding   round   製作   

今天看到一道有趣的css題,要求用html和css實現一個聖誕樹(上面一個小三角,下面一個大三角,最下面是一個矩形)?

你看到後腦子中的印象是什麼呢,三角形的做法,還是什麼,接下來看看我的製作過程。

<!DOCTYPE html>

<html>

<head>

<title>TODO supply a title</title>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<style type="text/css">

*{

margin: 0;

padding: 0;

}

#div1{

width: 500px;

height: 500px;

border: 5px #000 solid;

margin: 0 auto;

text-align: center;

}

h1{

color: #33ff33;

margin-top: 10px;

}

h2{

width: 0;

height:0;

border-top:60px #fff solid;

border-right:70px #fff solid;

border-bottom:70px #3333ff solid;

border-left:70px #fff solid;

position:relative;

left:180px;

}

h3{

width: 0;

height:0;

border-top:100px #fff solid;

border-right:100px #fff solid;

border-bottom:100px #3333ff solid;

border-left:100px #fff solid;

margin-left: 150px;

margin-top: -100px;

}

p{

width: 10px;

height:180px;

margin:0 auto;

background: red;

clear: both; /*不加清除浮動就會在h3下邊顯示*/

}

</style>

</head>

<body>

<div id="div1">

<h1>聖誕樹製作</h1>

<h2></h2>

<h3></h3>

<p></p>

</div>

</body>

</html>

 

效果如下:

Css畫聖誕樹

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.