天天看點

520這個日子就應該用程式員最浪漫的表白方式

在520這個浪漫的日子,你對你的女朋友表白了嗎?

朋友圈撒了一波狗糧,還是發了愛情520紅包,還是送去了朵鮮紅的玫瑰花。

520這個日子就應該用程式員最浪漫的表白方式

NO !NO !NO!這些太正常了,不是程式員表白的正确打開方式,今天教大家如何像女孩子浪漫表白,讓女孩子内心歡喜到想把你送她的禮物曬出來。

言歸正傳,接下來教大家制作動态相冊,保證俘獲她的芳心!!!

1、準備工作

(1)十二張和你女朋友有關的圖檔。可以是她單獨的,也可以是你的,也可以是你和她合影的,命名為img1、img2…img12。(這裡我用王者截圖來代替下哈,别說為什麼,都是淚,嗚嗚嗚)

520這個日子就應該用程式員最浪漫的表白方式

(2)一款Web前端開發軟體:HBuilder、Dreamweaver、Vscode等等。(這裡用HBubilder舉例,效果原理一樣)

520這個日子就應該用程式員最浪漫的表白方式

2、制作過程

(1)打開Web開發軟體HBuilder,建立一個Web項目,命名為動态相冊。

520這個日子就應該用程式員最浪漫的表白方式

(2)将剛剛準備的十二張圖檔複制到img檔案夾下。

520這個日子就應該用程式員最浪漫的表白方式

(3)右擊動态相冊——>建立——>HTML檔案,命名為love。

520這個日子就應該用程式員最浪漫的表白方式

它是顯示相冊主要功能的Html檔案,代碼如下,注釋蠻詳細的:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>2020520</title>
<link rel="stylesheet" href="css/cube.css" />
</head>
<body>
<!--/*外層最大容器*/-->
<div class="wrap">
<!--	/*包裹所有元素的容器*/-->

<div class="cube">
	<!--前面圖檔 -->
	<div class="out_front">
		<img src="img/img1.png"  class="pic" >
	</div>
	<!--後面圖檔 -->
	<div class="out_back">
		<img src="img/img2.png"  class="pic">
	</div>
	<!--左面圖檔 -->
	<div class="out_left">
		<img src="img/img3.png"  class="pic">
	</div>
	<!--右面圖檔 -->
	<div class="out_right">
		<img src="img/img4.png"  class="pic">
	</div>
	<!--上面圖檔 -->
	<div class="out_top">
		<img src="img/img5.png"  class="pic">
	</div>
	<!--底面圖檔 -->
	<div class="out_bottom">
		<img src="img/img6.png"  class="pic">
	</div>
	<!--小正方體 --> 
	<span class="in_front">
		<img src="img/img7.png" class="in_pic" />
	</span>
	<span class="in_back">
		 <img src="img/img8.png" class="in_pic" />
	</span>
	<span class="in_left">
		<img src="img/img9.png" class="in_pic" />
	</span>
	<span class="in_right">
		<img src="img/img10.png" class="in_pic" />
	</span>
	<span class="in_top">
		<img src="img/img11.png" class="in_pic" />
	</span>
	<span class="in_bottom">
		<img src="img/img12.png" class="in_pic" />
	</span>
</div>
</div>
//下面我加了段歌詞,大家也可以換成情話
<div>
	<marquee><font size="10" style="font-family: '微軟雅黑';color: red;">
		我想就這樣牽着你的手不放開</font></marquee>
	<marquee><font size="10" style="font-family: '微軟雅黑';color: yellow;">
		愛可不可以簡簡單單沒有傷害</font></marquee>
		<marquee><font size="10" style="font-family: '微軟雅黑';color: blue;">
		你 靠着我的肩膀</font></marquee>
		<marquee><font size="10" style="font-family: '微軟雅黑';color: pink;">
		你 在我胸口睡着</font></marquee>	
</div>
</body>
</html>

           

(4)右擊CSS——>建立——>CSS檔案,命名為cube,複制代碼。

520這個日子就應該用程式員最浪漫的表白方式

代碼如下:

html{
	background:black;
    height: 100%;	
}
/*最外層容器樣式*/
.wrap{
	width: 10px;
	height: 10px;
	/*改變左右上下,圖檔方塊移動*/
	margin: 200px 400px;
	position: relative;
	
}
/*包裹所有容器樣式*/
.cube{
	width:600px;
	height:400px;
	margin: 0 auto;
	transform-style: preserve-3d;
	transform: rotateX(-30deg) rotateY(-80deg);
	-webkit-animation: rotate 20s infinite;
	/*勻速*/
	animation-timing-function: linear;
}
@-webkit-keyframes rotate{
	from{transform: rotateX(0deg) rotateY(0deg);}
	to{transform: rotateX(360deg) rotateY(360deg);}
}
.cube div{
	position: absolute;
	width: 300px;
	height: 300px;
	opacity: 0.8;
	transition: all .4s;
}
/*定義所有圖檔樣式*/
.pic{
	width: 300px;
	height: 300px;
}
.cube .out_front{
	transform: rotateY(0deg) translateZ(150px);
}
.cube .out_back{
	transform: translateZ(-150px) rotateY(180deg);
}
.cube .out_left{
	transform: rotateY(90deg) translateZ(150px);
}
.cube .out_right{
	transform: rotateY(-90deg) translateZ(150px);
}
.cube .out_top{
	transform: rotateX(90deg) translateZ(150px);
}
.cube .out_bottom{
	transform: rotateX(-90deg) translateZ(150px);
}
/*定義小正方體樣式*/
.cube span{
	display: bloack;
	width: 200px;
	height: 200px;
	position: absolute;
	top: 50px;
	left: 50px;
}
.cube .in_pic{
	width: 200px;
	height: 200px;
}
.cube .in_front{
	transform: rotateY(0deg) translateZ(100px);
}
.cube .in_back{
	transform: translateZ(-100px) rotateY(180deg);
}
.cube .in_left{
	transform: rotateY(90deg) translateZ(100px);
}
.cube .in_right{
	transform: rotateY(-90deg) translateZ(100px);
}
.cube .in_top{
	transform: rotateX(90deg) translateZ(100px);
}
.cube .in_bottom{
	transform: rotateX(-90deg) translateZ(100px);
}
/*滑鼠移入後樣式*/
.cube:hover .out_front{
	transform: rotateY(0deg) translateZ(400px);
}
.cube:hover .out_back{
	transform: translateZ(-400px) rotateY(180deg);
}
.cube:hover .out_left{
	transform: rotateY(90deg) translateZ(400px);
}
.cube:hover .out_right{
	transform: rotateY(-90deg) translateZ(400px);
}
.cube:hover .out_top{
	transform: rotateX(90deg) translateZ(400px);
}
.cube:hover .out_bottom{
	transform: rotateX(-90deg) translateZ(400px);
}
           

3、運作效果展示

儲存代碼并用Edge浏覽器運作,QQ浏覽器不支援運作,自帶的Edge浏覽器可以完美運作。會發現相冊變成相嵌的内外兩個無蓋正方體,在網頁上自由自在地飄動着。

520這個日子就應該用程式員最浪漫的表白方式

滑鼠放上去,相冊會散開,是不是很酷!

520這個日子就應該用程式員最浪漫的表白方式

歌詞的話可加可不加,背景其實也可以加一張大圖,這裡的話大家可以自由發揮。

520這個日子就應該用程式員最浪漫的表白方式

趕緊拿去送給女朋友吧,覺得還不錯的點個贊呦!

I can make it through the rain.I can stand up once.