【前端】夯实基础 css/html/js 50个练手项目(持续更新)
这个问题看起来像是在寻求一些实践项目来提升他们的前端技能。下面是一些基于HTML, CSS, 和JavaScript的练手项目。
- 导航条效果
- 响应式布局
- 滑动菜单
- 图片轮播
- 滑动解锁
- 选项卡
- 滑动结束删除项
- 进度条
- 滑动显示更多
- 下拉刷新
以下是每个项目的简要代码示例:
- 导航条效果
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</nav>
- 响应式布局
@media screen and (max-width: 600px) {
body {
background-color: lightblue;
}
}
- 滑动菜单
<div class="menu">
<button class="menu-btn">☰ Menu</button>
<ul class="menu-items">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
- 图片轮播
<div class="slideshow-container">
<div class="mySlides fade">
<img src="img1.jpg" style="width:100%">
</div>
<!-- Next and previous buttons -->
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
- 滑动解锁
document.addEventListener('mousemove', function(e) {
let x = e.clientX;
let y = e.clientY;
let lock = document.querySelector('.lock');
lock.style.left = `${x}px`;
lock.style.top = `${y}px`;
});
- 选项卡
<div class="tab">
<button class="tablinks" onclick="openTab(event, 'tab1')">Tab 1</button>
<button class="tablinks" onclick="openTab(event, 'tab2')">Tab 2</button>
</div>
<div id="tab1" class="tabcontent">
<h3>Tab 1</h3>
<p>This is tab 1 content.</p>
</div>
<div id="tab2" class="tabcontent">
<h3>Tab 2</h3>
<p>This is tab 2 content.</p>
</div>
- 滑动结束删除项
<ul>
<li>Item 1 <button onclick="deleteItem(this)">Delete</button></li>
<li>Item 2 <button onclick="deleteItem(this)">Delete</button></li>
<li>Item 3 <button onclick="deleteItem(this)">Delete</button></li>
</ul>
- 进度条
<div class="progress-bar-container">
<div class="progress-bar" style="width: 25%"></div>
</div>
- 滑动显示更多
<div class="more-container">
<div class="more-button">Show more ⬇</div>
<div class="more-text">
Lorem ipsum dolor sit amet, co
评论已关闭