写一个github的星球大战前端页面
时间: 2023-11-30 10:33:51 浏览: 164
xicky.github.io:一个github页面
好的,我了解了。首先,您需要创建一个新的 GitHub 仓库来存储您的前端代码。然后,您可以使用 HTML、CSS 和 JavaScript 来编写您的星球大战前端页面。
以下是一个简单的代码示例,用于创建一个基本的星球大战页面:
```html
<!DOCTYPE html>
<html>
<head>
<title>Star Wars</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<header>
<h1>Star Wars</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Movies</a></li>
<li><a href="#">Characters</a></li>
<li><a href="#">Planets</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2>Featured Movie</h2>
<div class="movie-container">
<img src="https://images.unsplash.com/photo-1589945381786-1b2a2b6f7a6d?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTZ8fHN0YXIlMjB3YXJzfGVufDB8fDB8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="Star Wars Episode IX: The Rise of Skywalker">
<h3>Star Wars Episode IX: The Rise of Skywalker</h3>
<p>The surviving members of the resistance face the First Order once again, and the legendary conflict between the Jedi and the Sith reaches its peak bringing the Skywalker saga to its end.</p>
</div>
</section>
<section>
<h2>Featured Character</h2>
<div class="character-container">
<img src="https://images.unsplash.com/photo-1617129213797-9c9f13b38f6b?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8Y2hhcmFjdGVyJTIwYmFzdGFyZGVuJTIwcGxhbmV0fGVufDB8fDB8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="Chewbacca">
<h3>Chewbacca</h3>
<p>Chewbacca, a legendary Wookiee warrior and co-pilot of the Millennium Falcon, played a vital role in the Galactic Civil War and the Clone Wars.</p>
</div>
</section>
<section>
<h2>Featured Planet</h2>
<div class="planet-container">
<img src="https://images.unsplash.com/photo-1617129475124-bc4b6d4f08c8?ixid=MnwxMjA3fDB8MHxzZWFyY2h8M3x8cGxhbmV0JTIwZGVzaWdufGVufDB8fDB8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="Tatooine">
<h3>Tatooine</h3>
<p>Tatooine is a desert planet located in the Outer Rim of the galaxy. It is known for its many inhabitants, including Jawas, Tusken Raiders, and the Hutts.</p>
</div>
</section>
</main>
<footer>
<p>© 2021 Star Wars. All rights reserved.</p>
</footer>
</body>
</html>
```
然后,您可以使用 CSS 样式表来定义您的页面的外观和样式,例如:
```css
body {
font-family: Arial, sans-serif;
background-color: #000;
color: #fff;
}
header {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 20px;
background-color: #333;
}
h1 {
font-size: 4rem;
margin: 0;
}
nav ul {
display: flex;
list-style: none;
margin: 0;
padding: 0;
}
nav li {
margin: 0 20px;
}
nav a {
color: #fff;
text-decoration: none;
}
main {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: 50px;
}
section {
flex-basis: 30%;
margin-bottom: 50px;
}
.movie-container, .character-container, .planet-container {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
img {
max-width: 100%;
height: auto;
margin-bottom: 20px;
}
h3 {
font-size: 2rem;
margin: 0;
}
p {
line-height: 1.5;
margin: 0;
}
footer {
text-align: center;
padding: 20px;
background-color: #333;
}
```
最后,您可以使用 JavaScript 来为您的页面添加一些交互性和动态效果,例如:
```js
const movieContainer = document.querySelector('.movie-container');
const characterContainer = document.querySelector('.character-container');
const planetContainer = document.querySelector('.planet-container');
movieContainer.addEventListener('click', () => {
alert('You clicked on the featured movie!');
});
characterContainer.addEventListener('mouseover', () => {
characterContainer.classList.add('highlighted');
});
characterContainer.addEventListener('mouseout', () => {
characterContainer.classList.remove('highlighted');
});
planetContainer.addEventListener('click', () => {
planetContainer.innerHTML = '<img src="https://images.unsplash.com/photo-1599219391627-23cfd3f8bf44?ixid=MnwxMjA3fDB8MHxzZWFyY2h8OHx8cGxhbmV0JTIwZGVzaWduJTIwYmFzdGFyZGVuJTIwcGxhbmV0fGVufDB8fDB8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="Alderaan"><h3>Alderaan</h3><p>Alderaan was a planet located in the Core Worlds known for its peaceful culture and beautiful landscapes, until it was destroyed by the Death Star.</p>';
});
```
当然,这只是一个简单的示例。您可以根据自己喜好和需求进行更改和扩展。祝您好运!
阅读全文