php+html+css实现高考专属随机祝福页面

随机高考祝福页面

最近和一些高中同学准备创建校友会,并为高三的学弟学妹们送去毕业生们的随机高考祝福,因此有了这个页面的诞生,随机祝福是采用自己之前学php写的随机一言小demo。

页面访问——传送门

github点个star吧~


#先放效果图

 

#php源码

<?php
$filename='data.dat';
header('Content-type:text/html;charset=utf-8');
if(!file_exists($filename)){
echo $filename.'文件不存在';
}
$data=file_get_contents($filename);
$data=explode(PHP_EOL,$data);
$result=$data[array_rand($data)];

$result=str_replace(array("\r","\n","\r\n"),'',$result);
echo 'document.write("'.htmlspecialchars($result).'");';

?>

#html源码

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>梦独吟项目</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700i" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
<div class="wrapper">
<div class="book">
<div class="book__cover">
<div class="header-image"><div class="overlay"></div></div>
<div class="title-wrap">
<h1 class="article-title">高考祝福</h1>
</div>
<p class="book__cover-exerpt">

点击收下你的高考祝福!<br><br>

<span class="social">
<i class="fa fa-facebook"></i>
<i class="fa fa-twitter"></i>
<i class="fa fa-linkedin"></i>
<i class="fa fa-instagram"></i>
</span>

</p>

</div>
<div class="book__content">
<p><span class="drop-cap">#</span>
<script src="https://imapi.datealive.top/test/api.php"></script>
</div>
</div>

</div>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script>
"use strict";

$('.book').on('click', function () {
$(this).toggleClass('book--expanded');
});

</script>
</body>
</html>

#css源码

*{
    margin: 0;
    padding: 0;
   
  }
  body {
    background: #f3f4f4;
    font-family: 'Roboto Condensed', sans-serif;
    overflow: hidden;    
  }
  .mr2 {
    margin-right: 1rem;
  }
  .ml2 {
    margin-left: 1rem;
  }
  .article-title {
    font-size: 2.5rem;
    line-height: 1;
    font-family: "楷体","楷体_GB2312";
    text-align: center;
    letter-spacing: 0.025em;
    transition: font-size 0.45s ease-in-out, color 0.3s ease-out;
  }
  .header-image {
    height: 220px;
    background-image: url(./xiaomen.jpg);
    background-size: cover;
    background-position: center;
    margin-bottom: 3rem;
    position: relative;
    transition: all 0.45s ease-in-out;
  }
  .overlay {
    transition: all 0.3s ease-in-out;
    background: url();
    opacity: 0;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }
  .title-wrap {
    transform: translateY(0);
    transition: transform 0.45s ease-in;
  }
  .drop-cap {
    font-size: 55px;
    line-height: 28px;
    color: deepskyblue;
  }
  .wrapper {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .book__cover-exerpt {
    color: #6a6a6a;
    padding: 1rem 1.5rem;
    line-height: 1.6;
    text-align: center;
    opacity: 1;
    max-width: 370px;
    margin: 0 auto;
    display: block;
    transition: all 0.25s ease-in-out;
  }
   
  .book__cover {
    height: 100%;
    width: 100%;
  }
  .book__content {
    text-align: justify;
    word-wrap: break-word;
    font-size: 3rem;
    opacity: 0;
    transition: all 1.5s ease-in-out;
    max-width: 750px;
    margin: 0 auto 6rem;
    padding: 0 2rem;
  }
  .book__content p {
    line-height: 1.8;
    color: #3a3a3a;
    margin-bottom: 2.5rem;
  }
  .book {
    overflow: hidden;
    background: white;
    height: 580px;
    width: 400px;
    box-shadow: 0 20px 30px -10px #ccc;
    transition: all 0.5s ease-in-out;
  }
  .book:hover {
    box-shadow: 0 6px 50px 10px #cfcfcf;
  }
  .book--expanded {
    height: 100%;
    width: 100%;
    overflow-y: scroll;
  }
  .book--expanded .overlay {
    opacity: 0.95;
  }
  .book--expanded .article-title {
    color: white;
    font-size: 64px;
    letter-spacing: 0.05em;
  }
  .book--expanded .title-wrap {
    transform: translateY(-300px);
    color: white;
  }
  .book--expanded .book__cover-exerpt {
    opacity: 0;
  }
  .book--expanded .book__cover {
    height: 460px;
    margin-bottom: 6rem;
  }
  .book--expanded .book__content {
    opacity: 1;
  }
  .book--expanded .header-image {
    height: 100%;
  }
  span{
     margin-left: -35px;
  }
  span .fa {
     font-size: 17px;
     margin-left: 20px;
  }

data.dat的文件自己创建,并且在每行插入祝福语。

原创文章转载请声明~

点赞
  1. 风-陌说道:
    Google Chrome Windows 10

    膜拜大佬 :haha:

发表评论

昵称和uid可以选填一个,填邮箱必填(留言回复后将会发邮件给你)
tips:输入uid可以快速获得你的昵称和头像