用html+css样式,画背景图

图片描述

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>图片</title>
<style>
    div{height: 400px;width: 400px;background-size: 40px 40px; background-image: linear-gradient(45deg, #555 25%,transparent 25%,transparent 75%, #555 75%),linear-gradient(135deg,#555 25%,transparent 25%,transparent 75%, #555 75%);}
</style>
</head>
<body>
<div></div>
</body>
</html>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个使用HTML5、CSS和JavaScript的精致登录页面示例,带有背景图: ```html <!DOCTYPE html> <html> <head> <title>Login Page</title> <link rel="stylesheet" type="text/css" href="login.css"> </head> <body> <div class="bg-container"> <div class="login-container"> <h2>Login</h2> <form> <label for="username">Username:</label> <input type="text" id="username" name="username" required><br><br> <label for="password">Password:</label> <input type="password" id="password" name="password" required><br><br> <input type="submit" value="Login"> </form> </div> </div> <script type="text/javascript" src="login.js"></script> </body> </html> ``` ```css body { background: #f5f5f5; font-family: Arial, sans-serif; margin: 0; padding: 0; } .bg-container { background-image: url('background.jpg'); background-size: cover; background-position: center; height: 100vh; display: flex; align-items: center; justify-content: center; } .login-container { background: #fff; padding: 30px; border-radius: 5px; box-shadow: 0 0 5px rgba(0,0,0,0.3); max-width: 400px; } h2 { text-align: center; margin-bottom: 30px; } form label { display: block; margin-bottom: 10px; } form input[type="text"], form input[type="password"] { padding: 10px; border: none; border-radius: 5px; box-shadow: 0 0 5px rgba(0,0,0,0.1); width: 100%; margin-bottom: 20px; } form input[type="submit"] { background: #0077cc; color: #fff; border: none; border-radius: 5px; padding: 10px 20px; cursor: pointer; font-size: 16px; transition: background 0.3s ease; } form input[type="submit"]:hover { background: #0062a3; } ``` ```javascript const bgContainer = document.querySelector('.bg-container'); const formContainer = document.querySelector('.login-container'); bgContainer.style.height = `${window.innerHeight}px`; window.addEventListener('resize', () => { bgContainer.style.height = `${window.innerHeight}px`; }); ``` 这个页面使用了一个背景图作为页面的背景,并将其居中对齐。登录表单位于一个容器元素中,并将其居中对齐。页面还包含一些CSS样式,使表单更加美观。 JavaScript代码用于调整背景容器的高度,以使其始终填满窗口,并针对窗口大小的更改进行调整。 你可以根据自己的需求进一步修改和扩展这个页面,例如添加其他动效果或更改背景图像。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值