Home > Web Front-end > CSS Tutorial > Use HTML5 and CSS3 to make birthday cakes

Use HTML5 and CSS3 to make birthday cakes

不言
Release: 2018-06-20 09:50:34
Original
3862 people have browsed it

This article mainly introduces the use of HTML5 and CSS3 to realize the production of birthday cakes. It has a certain reference value. Now I share it with you. Friends in need can refer to it.

"Happy birthday to you, Happy birthday to you...", birthdays include birthday songs, and birthday cakes are also indispensable. This article mainly introduces in detail the birthday cake made by programmers using pure HTML5 CSS3. It has certain reference value. If you are interested Friends, you can refer to

. As a front-end developer, draw a simple cake to celebrate today's good day. The fun and sadness of a programmer's birthday. The writing is relatively simple, so take a look if you are interested.

Let me send you a rendering first

The cake is divided into three parts, the bottom cake, the top cake and the candle part. The layout structure of HTML is also laid out according to these three parts. The other is to use CSS positioning and CSS3 rotate, inner and outer shadows and other effects to adjust the styles of some DOM elements. It's relatively simple, I believe all coders understand it.

I won’t go into details about the others.

The complete HTML code and CSS code are given below

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

<!DOCTYPE html>

<html>

<head lang="en">

    <meta charset="UTF-8">

    <title></title>

    <style>

        .birthday .container{

            width:600px;

            height:600px;

            margin:0px auto;

            background: #fafafa;

            border-radius:5px;

            position: relative;

        }

 

        /**

       ** 顶层的

       **/

 

        .birthday .top-one{

            position: absolute;

            width:280px;

            height: 280px;

            bottom: 200px;

            left:160px;

        }

 

        .birthday .top-one .bottom{

            position: absolute;

            width:280px;

            height: 280px;

            bottom:-30px;

            border:1px solid #3e2001;

            border-radius: 140px;

            transform: rotateX(60deg);

            z-index: 4;

            background: #3e2001;

            box-shadow: 0px 0px 20px #3e2001;

        }

        .birthday .top-one .top{

            position: absolute;

            width:280px;

            height: 280px;

            top:-50px;

            border-radius: 140px;

            background: #FFFFFF;

            transform: rotateX(60deg);

            box-shadow: 2px 2px 20px #b7b7b7;

            z-index: 6;

            background: -webkit-repeating-radial-gradient(circle, #783d01, #3e2001 10px, #914909 10px,white 20px);

            background: -moz-repeating-radial-gradient(circle, #783d01, #3e2001 10px,#914909 10px,white 20px);

        }

        .birthday .top-one .side{

            position: absolute;

            top:95px;

            width:280px;

            height: 70px;

            border:1px solid #3e2001;

            border-top-width: 0px;

            border-bottom-width: 0px;

            background: #FFFFFF;

            z-index: 5;

            background: #3e2001;

        }

 

 

        /**

        ** 底层的

        **/

        .birthday .bottom-one{

            position: absolute;

            width:400px;

            height: 400px;

            bottom: 0px;

            left:100px;

        }

        .birthday .bottom-one .bottom{

            position: absolute;

            width:400px;

            height: 400px;

            bottom:-30px;

            border:1px solid #914909;

            border-radius: 200px;

            transform: rotateX(60deg);

            box-shadow: 2px 2px 20px #914909;

            z-index: 1;

            background: #3e2001;

            overflow: hidden;

        }

        .birthday .bottom-one .line{

            position: absolute;

            width:400px;

            height: 400px;

            border-radius: 200px;

            z-index: 1;

        }

        .birthday .bottom-one .line1{

            bottom: 30px;

            border:5px solid #783d01;

            left:-5px;

            z-index: 1;

        }

 

        .birthday .bottom-one .top{

            position: absolute;

            width:400px;

            height: 400px;

            top:-100px;

            border:1px solid #3e2001;

            border-radius: 200px;

            background: #FFFFFF;

            transform: rotateX(60deg);

            z-index: 3;

            background: #783d01;

            box-shadow: inset 0px 0px 20px #3e2001;

 

        }

 

        .birthday .bottom-one .side{

            position: absolute;

            top:100px;

            width:400px;

            height: 130px;

            border:1px solid #3e2001;

            border-top-width: 0px;

            border-bottom-width: 0px;

            background: #3e2001;

            z-index: 2;

 

        }

 

 

        /**

        ** 底层的文字

        **/

        .birthday .flower{

            position: relative;

            text-align: justify;

            z-index: 9;

            top:200px;

            font-size: 32px;

            font-family: "Helvetica Neue", "Noto Sans CJK SC", "Source Han Sans CN";

            color:#FFFFFF;

            font-weight: bold;

        }

        .birthday .flower:after{

            content:"";

            display:inline-block;

            position: relative;

            width:100%;

        }

 

        .birthday .flower i{

            position: relative;

            width:80px;

            line-height: 80px;

            display: inline-block;

            border-radius: 50%;

            border:2px solid #783d01;

            text-align: center;

 

        }

 

        /**

        ** 顶层的文字

        **/

        .birthday .top-one .text{

            width:100%;

            text-align: center;

            position: absolute;

            top:165px;

            z-index: 9;

            margin:0px auto;

            font-size: 30px;

            color:#FFFFFF;

            transform: rotateX(60deg) skew(10deg,20deg);

        }

 

 

        /**

         ** 蜡烛

        **/

 

        .birthday .candle{

            width:10px;

            height:80px;

            margin:0px auto;

            position: absolute;

            left:295px;

            top:130px;

            z-index: 9;

        }

        .birthday .candle .body{

            width:10px;

            height:70px;

            margin:0px auto;

            background: red;

            border-bottom-width: 0px;

        }

 

        .birthday .candle .top{

            width:10px;

            height: 10px;

            border-radius: 5px;

            transform: rotateX(60deg);

            position: relative;

            top:5px;

            background: red;

        }

        .birthday .candle .bottom{

            width:10px;

            height: 10px;

            border-radius: 5px;

            transform: rotateX(60deg);

            position: relative;

            bottom:5px;

            background: red;

            box-shadow: 1px 1px 10px red;

        }

 

        .birthday .candle .fire{

            position: absolute;

            width:6px;

            height: 6px;

            left:2px;

            transform: rotate(45deg);

            background: #ffd507;

            box-shadow: 0px 0px 20px #ffff00, 2px 2px 10px red;

 

        }

 

 

    </style>

 

</head>

<body>

    <p class="birthday">

        <p class="container">

 

            <p class="candle">

                <p class="fire"></p>

                <p class="top"></p>

                <p class="body"></p>

                <p class="bottom"></p>

            </p>

 

            <p class="top-one">

                <p class="top"></p>

                <p class="side"></p>

                <p class="bottom"></p>

                <p class="text">

                    Happy Birthday

                </p>

            </p>

 

            <p class="bottom-one">

                <p class="top"></p>

                <p class="side"></p>

                <p class="bottom">

                    <p class="line line1"></p>

                </p>

                <p class="flower">

                    <i style="top:-20px;transform: rotateY(50deg)">生</i>

                    <i style="top:15px;transform: rotateY(30deg)">日</i>

                    <i style="top:15px;transform: rotateY(30deg)">快</i>

                    <i style="top:-20px;transform: rotateY(50deg)">乐</i>

                </p>

            </p>

        </p>

    </p>

</body>

</html>

Copy after login

okay, a small demo developed by Qingsheng. You can try to use Canvas canvas or SVG to try it in the future. Thanks for reading.

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to use jQuery and HTML5 to realize the special effect of changing clothes by shaking the phone

Using 63 lines of code in html5 Realize the snake game

The above is the detailed content of Use HTML5 and CSS3 to make birthday cakes. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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