flex: 1; display: flex; justify-content: space-between; flex-direction: column; padding-left: 10px; box-sizing: border-box;
时间: 2023-10-27 13:41:44 浏览: 54
这是一段CSS样式代码,具体含义如下:
- `flex:1`:将该元素设置为一个flex容器,并将该容器的剩余空间平均分配给该元素。
- `display:flex`:将该元素设置为一个flex容器。
- `justify-content: space-between`:将该容器中的项目沿主轴对齐,使第一个项目位于容器的起始位置,最后一个项目位于容器的结束位置,其余项目平均分布在容器中。
- `flex-direction:column`:设置主轴方向为垂直方向。
- `padding-left:10px`:设置该元素左侧内边距为10px。
- `box-sizing:border-box`:设置该元素的盒模型为border-box,即内边距和边框的宽度不会增加元素的总宽度和高度。
相关问题
html css js 宠物网站 代码 功能:登录注册,关于我们,宠物介绍,宠物商品
以下是一个简单的宠物网站的HTML、CSS和JavaScript代码,包括登录注册、关于我们、宠物介绍、宠物商品等功能。
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>宠物网站</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>宠物网站</h1>
<nav>
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">宠物介绍</a></li>
<li><a href="#">宠物商品</a></li>
<li><a href="#">关于我们</a></li>
</ul>
<div id="user">
<a href="#" id="login">登录</a>
<a href="#" id="register">注册</a>
</div>
</nav>
</header>
<main>
<section id="intro">
<h2>欢迎来到宠物世界</h2>
<p>我们致力于为您提供最好的宠物服务和产品,让您的爱宠生活更加美好。</p>
</section>
<section id="pet">
<h2>宠物介绍</h2>
<div class="pet-item">
<img src="dog.jpg" alt="狗狗">
<h3>狗狗</h3>
<p>狗狗是人类最忠诚的伙伴,它们陪伴我们走过人生的每一个阶段。</p>
</div>
<div class="pet-item">
<img src="cat.jpg" alt="猫咪">
<h3>猫咪</h3>
<p>猫咪是人类的好朋友,它们温顺可爱,是家庭中的重要成员。</p>
</div>
<div class="pet-item">
<img src="bird.jpg" alt="小鸟">
<h3>小鸟</h3>
<p>小鸟是生活中的美丽元素,它们能够带给我们无尽的快乐。</p>
</div>
</section>
<section id="product">
<h2>宠物商品</h2>
<div class="product-item">
<img src="dog-food.jpg" alt="狗粮">
<h3>狗粮</h3>
<p>我们提供各种口味、各种品牌的狗粮,保证您的爱宠健康成长。</p>
</div>
<div class="product-item">
<img src="cat-toy.jpg" alt="猫玩具">
<h3>猫玩具</h3>
<p>我们提供各种有趣的猫玩具,让您的猫咪不再无聊。</p>
</div>
<div class="product-item">
<img src="bird-cage.jpg" alt="鸟笼">
<h3>鸟笼</h3>
<p>我们提供各种款式、各种材质的鸟笼,让您的小鸟住得舒适。</p>
</div>
</section>
<section id="about">
<h2>关于我们</h2>
<p>我们是一家专业的宠物服务和产品提供商,我们的使命是为您的爱宠带来更好的生活。</p>
</section>
</main>
<footer>
<p>版权所有 © 2021 宠物网站</p>
</footer>
<div id="login-modal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<h2>用户登录</h2>
<form>
<label for="username">用户名:</label>
<input type="text" id="username" name="username" required>
<label for="password">密码:</label>
<input type="password" id="password" name="password" required>
<input type="submit" value="登录">
</form>
</div>
</div>
<div id="register-modal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<h2>用户注册</h2>
<form>
<label for="email">邮箱:</label>
<input type="email" id="email" name="email" required>
<label for="username">用户名:</label>
<input type="text" id="username" name="username" required>
<label for="password">密码:</label>
<input type="password" id="password" name="password" required>
<input type="submit" value="注册">
</form>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
```
CSS代码:
```css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, Helvetica, sans-serif;
}
header {
background: #333;
color: #fff;
padding: 20px;
}
h1 {
font-size: 32px;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
}
nav ul {
display: flex;
list-style: none;
}
nav ul li a {
color: #fff;
text-decoration: none;
padding: 10px;
}
nav ul li a:hover {
background: #fff;
color: #333;
}
#user {
display: flex;
align-items: center;
}
#user a {
color: #fff;
margin-left: 20px;
}
#user a:hover {
text-decoration: underline;
}
main {
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
}
h2 {
font-size: 24px;
margin-bottom: 20px;
}
section {
margin-bottom: 50px;
}
.pet-item {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 20px;
}
.pet-item img {
width: 200px;
height: 200px;
object-fit: cover;
border-radius: 50%;
margin-bottom: 10px;
}
.product-item {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 20px;
}
.product-item img {
width: 200px;
height: 200px;
object-fit: cover;
border-radius: 10px;
margin-bottom: 10px;
}
#login-modal, #register-modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0,0,0,0.5);
}
.modal-content {
background-color: #fff;
margin: 10% auto;
padding: 20px;
border: 1px solid #888;
width: 50%;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover, .close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
@media (max-width: 768px) {
header {
flex-direction: column;
align-items: center;
}
nav ul {
flex-direction: column;
margin-top: 20px;
}
nav ul li {
margin-bottom: 10px;
}
#user {
margin-top: 20px;
}
#login-modal .modal-content, #register-modal .modal-content {
width: 80%;
}
}
```
JavaScript代码:
```javascript
// 获取登录和注册按钮
var loginBtn = document.getElementById('login');
var registerBtn = document.getElementById('register');
// 获取登录和注册弹出框
var loginModal = document.getElementById('login-modal');
var registerModal = document.getElementById('register-modal');
// 获取关闭按钮
var loginClose = loginModal.getElementsByClassName('close')[0];
var registerClose = registerModal.getElementsByClassName('close')[0];
// 点击登录按钮弹出登录框
loginBtn.onclick = function() {
loginModal.style.display = 'block';
}
// 点击注册按钮弹出注册框
registerBtn.onclick = function() {
registerModal.style.display = 'block';
}
// 点击关闭按钮关闭弹出框
loginClose.onclick = function() {
loginModal.style.display = 'none';
}
registerClose.onclick = function() {
registerModal.style.display = 'none';
}
// 点击其他区域关闭弹出框
window.onclick = function(event) {
if (event.target == loginModal) {
loginModal.style.display = 'none';
}
if (event.target == registerModal) {
registerModal.style.display = 'none';
}
}
```
以上代码只是一个简单的示例,实际的宠物网站需要根据需求和具体情况进行修改和完善。
https://1drv.ms/i/s!Au5bBzCn0l5KgWbgVcV9VZarWU5k?e=JYs03q
好的,我已经查看了您提供的效果图。以下是我为您编写的HTML和CSS代码,以及效果图的静态网页演示。请注意,这只是一个简单的示例,您可以根据需要进行修改和优化。
HTML代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>静态网页示例</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<div class="logo">
<img src="https://i.imgur.com/JaDzXkf.png" alt="logo">
</div>
<nav>
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">产品</a></li>
<li><a href="#">服务</a></li>
<li><a href="#">关于我们</a></li>
<li><a href="#">联系我们</a></li>
</ul>
</nav>
</header>
<main>
<section class="banner">
<h1>欢迎光临</h1>
<p>这里是一个简单的静态网页示例</p>
<a href="#" class="button">了解更多</a>
</section>
<section class="features">
<div class="feature">
<img src="https://i.imgur.com/9bKIZ8b.png" alt="feature 1">
<h2>功能1</h2>
<p>这里是功能1的描述信息</p>
</div>
<div class="feature">
<img src="https://i.imgur.com/3r6j4RE.png" alt="feature 2">
<h2>功能2</h2>
<p>这里是功能2的描述信息</p>
</div>
<div class="feature">
<img src="https://i.imgur.com/8gI9Wun.png" alt="feature 3">
<h2>功能3</h2>
<p>这里是功能3的描述信息</p>
</div>
</section>
<section class="services">
<h2>我们的服务</h2>
<ul>
<li>服务1</li>
<li>服务2</li>
<li>服务3</li>
<li>服务4</li>
</ul>
</section>
<section class="about-us">
<h2>关于我们</h2>
<p>这里是关于我们的描述信息</p>
</section>
<section class="contact-us">
<h2>联系我们</h2>
<form>
<input type="text" placeholder="姓名">
<input type="email" placeholder="邮箱">
<textarea placeholder="留言"></textarea>
<button type="submit">发送</button>
</form>
</section>
</main>
<footer>
<p>版权所有 © 2021 静态网页示例</p>
</footer>
</body>
</html>
```
CSS代码:
```css
/* 全局样式 */
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
font-size: 16px;
line-height: 1.5;
color: #333;
}
/* 头部样式 */
header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 50px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.logo img {
height: 50px;
}
nav ul {
display: flex;
}
nav li {
margin-left: 20px;
}
nav li:first-child {
margin-left: 0;
}
nav a {
color: #333;
text-decoration: none;
}
nav a:hover {
color: #f00;
}
/* 主要内容样式 */
main {
padding: 50px;
}
.banner {
text-align: center;
margin-bottom: 50px;
}
.banner h1 {
font-size: 48px;
margin-bottom: 20px;
}
.banner p {
font-size: 24px;
margin-bottom: 40px;
}
.button {
display: inline-block;
padding: 10px 20px;
background-color: #f00;
color: #fff;
text-decoration: none;
border-radius: 5px;
}
.button:hover {
background-color: #d00;
}
.features {
display: flex;
justify-content: space-between;
margin-bottom: 50px;
}
.feature {
flex-basis: 30%;
text-align: center;
}
.feature img {
height: 100px;
margin-bottom: 20px;
}
.feature h2 {
font-size: 24px;
margin-bottom: 10px;
}
.feature p {
font-size: 16px;
}
.services {
margin-bottom: 50px;
}
.services h2 {
font-size: 24px;
margin-bottom: 20px;
}
.services ul {
list-style: none;
margin: 0;
padding: 0;
}
.services li {
margin-bottom: 10px;
}
.about-us {
margin-bottom: 50px;
}
.about-us h2 {
font-size: 24px;
margin-bottom: 20px;
}
.contact-us {
margin-bottom: 50px;
}
.contact-us h2 {
font-size: 24px;
margin-bottom: 20px;
}
form {
display: flex;
flex-direction: column;
}
form input,
form textarea {
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 5px;
}
form button {
padding: 10px 20px;
background-color: #f00;
color: #fff;
text-decoration: none;
border: none;
border-radius: 5px;
}
form button:hover {
background-color: #d00;
}
/* 底部样式 */
footer {
text-align: center;
padding: 20px;
background-color: #f00;
color: #fff;
}
```
效果图静态网页演示链接:
https://codepen.io/yuanyuanz/pen/OJWJLmM
希望这样可以帮助您!