使用HTML CSS 写一个元旦贺卡
时间: 2023-07-20 19:12:40 浏览: 53
好的,这是一个简单的HTML和CSS代码,可以用来制作元旦贺卡:
HTML代码:
```
<!DOCTYPE html>
<html>
<head>
<title>元旦贺卡</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="card">
<h1>新年快乐!</h1>
<p>祝愿您在新的一年里身体健康,心情愉快,事业有成,家庭幸福!</p>
<img src="https://img-blog.csdn.net/20171229110225018" alt="元旦贺卡">
</div>
</body>
</html>
```
CSS代码:
```
.card {
background-color: #fff;
border-radius: 10px;
box-shadow: 0px 0px 10px #ccc;
margin: 50px auto;
max-width: 600px;
padding: 30px;
text-align: center;
}
h1 {
font-size: 36px;
margin-bottom: 20px;
}
p {
font-size: 24px;
margin-bottom: 30px;
}
img {
max-width: 100%;
}
```
你可以将图片链接替换为自己喜欢的图片,然后用浏览器打开HTML文件,就可以看到制作好的元旦贺卡了。
相关问题
用HTML和css写一个贺卡代码
以下是一个简单的贺卡代码,使用 HTML 和 CSS 来制作:
```html
<!DOCTYPE html>
<html>
<head>
<title>贺卡</title>
<style>
body {
background-color: #FEE8E9;
margin: 0;
padding: 0;
}
.card {
background-color: #FFFFFF;
width: 600px;
height: 400px;
margin: auto;
margin-top: 50px;
border-radius: 20px;
box-shadow: 0px 0px 20px #CCC;
overflow: hidden;
}
.card img {
width: 100%;
height: 100%;
object-fit: cover;
filter: grayscale(100%);
opacity: 0.5;
}
.card h1 {
font-size: 60px;
color: #FFFFFF;
text-align: center;
margin-top: 80px;
text-shadow: 0px 0px 10px #000;
}
.card p {
font-size: 30px;
color: #FFFFFF;
text-align: center;
margin-top: 20px;
text-shadow: 0px 0px 10px #000;
}
.card:hover img {
filter: grayscale(0%);
opacity: 1;
}
</style>
</head>
<body>
<div class="card">
<img src="https://picsum.photos/600/400" alt="背景图片">
<h1>祝福语</h1>
<p>祝XXX生日快乐!</p>
</div>
</body>
</html>
```
这个代码会生成一个带有背景图片、祝福语和生日祝福的贺卡。你可以在 `img` 标签中更改图片的地址,也可以在 `h1` 和 `p` 标签中更改文字内容。如果需要更改贺卡的大小和颜色,可以在 CSS 中更改 `.card` 的属性。
使用html css写一个登录界面
以下是一个简单的登录界面的HTML和CSS代码示例:
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="container">
<h1>Login</h1>
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username" placeholder="Enter your username">
<label for="password">Password:</label>
<input type="password" id="password" name="password" placeholder="Enter your password">
<input type="submit" value="Login">
</form>
</div>
</body>
</html>
```
CSS代码(styles.css文件):
```css
.container {
width: 300px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
text-align: center;
}
h1 {
color: #333;
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
}
input[type="submit"] {
width: 100%;
background-color: #4CAF50;
color: #fff;
padding: 10px;
border: none;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
```
这个示例创建了一个简单的登录界面。在HTML中,使用`<form>`元素包含输入字段(用户名和密码)和一个提交按钮。CSS样式定义了容器样式、标题样式、输入字段样式和提交按钮样式。
你可以将上述HTML代码保存为一个名为`login.html`的文件,将CSS代码保存为一个名为`styles.css`的文件,确保两个文件在同一目录下,并在浏览器中打开`login.html`文件,即可看到登录界面。