Home Web Front-end H5 Tutorial How to make a birthday cake - but using HTML5+CSS3 code

How to make a birthday cake - but using HTML5+CSS3 code

May 21, 2017 pm 06:35 PM
css3 html5

"Happy birthday to you, happy birthday to you...", a birthday has a birthday song, and a birthday cake is also indispensable. This article mainly introduces in detail the birthday made by programmers using pure HTML5+CSS3 Cake has a certain reference value. Interested friends can refer to

. As a front-end developer, let’s draw a simple cake to celebrate today’s good day. The joy 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 using Canvas canvas or SVG in the future. I'll give it a try, thanks for reading.

The above is the detailed content of How to make a birthday cake - but using HTML5+CSS3 code. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1253
29
C# Tutorial
1227
24
Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

See all articles