Hongmu Notes
Home Language Notes HTML+CSS+Swiper realizes the idea of sliding left and right in three columns on NetEase Cloud mobile phone
Language Notes CSS JavaScript

HTML+CSS+Swiper realizes the idea of sliding left and right in three columns on NetEase Cloud mobile phone

HTML+CSS+Swiper realizes the idea of sliding left and right in three columns on NetEase Cloud mobile phone

20240108202621177-图片

First, use Swiper to enable left-right swiping!

Use HTML and CSS to implement a text and image layout display!

Code:

 隐藏内容:会员可查看
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <title>Music demo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
<link rel="stylesheet" href="https://unpkg.com/swiper@8/swiper-bundle.min.css">    
<script src="https://unpkg.com/swiper@8/swiper-bundle.js"> </script>  

  <style>
    html,
    body {
      position: relative;
      height: 100%;
	  max-width:466px
    }

    body {
      background: #eee;
      font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
      font-size: 14px;
      color: #000;
      margin: 0;
      padding: 0;
    }

    .swiper {
      width: 100%;
      height: 100%;
    }

    .swiper-slide {
      text-align: center;
      font-size: 16px;
      background: #fff;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .swiper-slide img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    body {
      background: #eee;
    }

    .swiper {
      width: 100%;
      height: 300px;
      margin: 20px 0;
    }
	.swiper-slide ul{
		height:300px;
		width:100%;
		list-style: none;
		margin: 0;
		padding: 0;
	}
	
	.swiper-slide ul li{
		height: 100px;
	}
	
	.musicLeft{
		width: 20%;
		float: left;
		height: 100%;
		background: #e6e7eb;
		text-align: center;
		display: flex;
		justify-content: center;
		align-items: center;
	}  
	.musicRight{
		width: 80%;
		float: right;
		height: 100%;
		background: #e6e7eb;
		position: relative;
	}
	.musicBox{
		float: left;
		height: 100%;
		width: 100%;
	}
	.musicBox img{
		width:80px;
		height:80px;
		border-radius: 10px;
	}
	.musicRight h3 , p{
		text-align: left;
		padding: 0 0 0 20px;
	}
	.musicRight h3{
		margin: 0;
		padding: 0;
		position: absolute;
		top: 30%;
		transform: translate(10px,-50%);
		font-weight: unset;
		font-size: 18px;
	}
	.musicRight p{
		margin: 0;
		padding: 0;
		position: absolute;
		top: 60%;
		transform: translate(10px,-50%);
		color: #605c56;
	}
	.musicRight font{
		background: #edd2db;
		padding: 2px;
		font-size: 14px;
		border-radius: 6px;
		color: #c41d1d;
		margin-right: 6px;
	}
  </style>
</head>

<body>
  <!-- Swiper -->
  <div class="swiper mySwiper">
    <div class="swiper-wrapper">
      <div class="swiper-slide">
		<ul>
			<li>
				<div class="musicBox">
					<div class="musicLeft">
						<img src="https://www.4s5.cn/wp-content/uploads/2023/02/f8a70c8797142232.jpg">
					</div>
					<div class="musicRight">
						<h3>如果当时</h3>
						<p><font>古风热门榜第一名</font>许嵩</p>
					</div>
				</div>
			</li>
			<li>
				<div class="musicBox">
					<div class="musicLeft">
						<img src="https://www.4s5.cn/wp-content/uploads/2023/02/f8a70c8797142232.jpg">
					</div>
					<div class="musicRight">
						<h3>素颜</h3>
						<p><font>流行热门榜第一名</font>许嵩</p>
					</div>
				</div>
			</li>
			<li>
				<div class="musicBox">
					<div class="musicLeft">
						<img src="https://www.4s5.cn/wp-content/uploads/2023/02/f8a70c8797142232.jpg">
					</div>
					<div class="musicRight">
						<h3>悬溺</h3>
						<p>葛东琪 </p>
					</div>
				</div>
			</li>
		</ul>
	  </div>
		<div class="swiper-slide">
		<ul>
			<li>
				<div class="musicBox">
					<div class="musicLeft">
						<img src="https://www.4s5.cn/wp-content/uploads/2023/02/f8a70c8797142232.jpg">
					</div>
					<div class="musicRight">
						<h3>如果当时</h3>
						<p><font>古风热门榜第一名</font>许嵩</p>
					</div>
				</div>
			</li>
			<li>
				<div class="musicBox">
					<div class="musicLeft">
						<img src="https://www.4s5.cn/wp-content/uploads/2023/02/f8a70c8797142232.jpg">
					</div>
					<div class="musicRight">
						<h3>素颜</h3>
						<p><font>流行热门榜第一名</font>许嵩</p>
					</div>
				</div>
			</li>
			<li>
				<div class="musicBox">
					<div class="musicLeft">
						<img src="https://www.4s5.cn/wp-content/uploads/2023/02/f8a70c8797142232.jpg">
					</div>
					<div class="musicRight">
						<h3>悬溺</h3>
						<p>葛东琪 </p>
					</div>
				</div>
			</li>
		</ul>
	  </div>
    
	<div class="swiper-slide">
		<ul>
			<li>
				<div class="musicBox">
					<div class="musicLeft">
						<img src="https://www.4s5.cn/wp-content/uploads/2023/02/f8a70c8797142232.jpg">
					</div>
					<div class="musicRight">
						<h3>如果当时</h3>
						<p><font>古风热门榜第一名</font>许嵩</p>
					</div>
				</div>
			</li>
			<li>
				<div class="musicBox">
					<div class="musicLeft">
						<img src="https://www.4s5.cn/wp-content/uploads/2023/02/f8a70c8797142232.jpg">
					</div>
					<div class="musicRight">
						<h3>素颜</h3>
						<p><font>流行热门榜第一名</font>许嵩</p>
					</div>
				</div>
			</li>
			<li>
				<div class="musicBox">
					<div class="musicLeft">
						<img src="https://www.4s5.cn/wp-content/uploads/2023/02/f8a70c8797142232.jpg">
					</div>
					<div class="musicRight">
						<h3>悬溺</h3>
						<p>葛东琪 </p>
					</div>
				</div>
			</li>
		</ul>
	  </div>
      
    </div>
  </div>

</script>

  <script>
    var swiper = new Swiper(".mySwiper", {
      spaceBetween: 30,
      pagination: {
        el: ".swiper-pagination",
        clickable: true,
      },
    });
  </script>
</body>

</html>

 

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

css positioning

css positioning Language Notes CSS

Syntax: position: static | relative | absolute | fixed | center | page | sticky Default value: static Applies to: All elements except the display attribute defined as table-column-group | table-column Inheritance: No Animation: No...
👁 119

Recommended reading

Environmental Waste Gas and Wastewater Treatment Project Website Template 0102

Environmental Waste Gas and Wastewater Treatment Project Website Template 0102 Practical Collection Yiyou template

This EyouCMS template is ideal for environmental protection, exhaust gas and wastewater treatment, as well as engineering enterprises. Its eco-friendly and tech-driven design effectively showcases exhaust gas and wastewater treatment technologies, engineering projects, and customized solutions. It helps environmental engineering firms demonstrate their expertise online and attract both industrial and municipal clients. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS...
👁 46
(Adaptive mobile version) pbootCMS automotive parts and accessories website template; Download source code for an automotive maintenance service website – 0655

(Adaptive mobile version) pbootCMS automotive parts and accessories website template; Download source code for an automotive maintenance service website – 0655 Practical Collection pbootcms Template

A PbootCMS website template for automotive parts and repair services, compatible with both PC and WAP devices. The design features a rugged, professional aesthetic, making it ideal for showcasing automotive components, maintenance and repair services, and more. This template helps automotive parts manufacturers showcase their products online and expand their customer base in the automotive aftermarket. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn...
👁 49
Landscape Design & Creative Greening Company Website Template 0729

Landscape Design & Creative Greening Company Website Template 0729 Practical Collection Yiyou template

An EyouCMS website template designed specifically for landscape design and creative landscaping companies. Its natural and artistic design style is ideal for showcasing landscape design projects, landscaping projects, innovative solutions, and brand stories. This template helps landscape design firms effectively demonstrate their expertise online and attract high-end project clients. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS...
👁 34
(PC+WAP) Exhibition-related PBootCMS website template; Download source code for an exhibition equipment and stage rental website – 0040

(PC+WAP) Exhibition-related PBootCMS website template; Download source code for an exhibition equipment and stage rental website – 0040 Practical Collection pbootcms Template

A PbootCMS website template designed for the exhibition and stage equipment rental industry, compatible with both PC and WAP mobile devices. Its sophisticated, modern design effectively showcases the professionalism and scale of trade shows and events. The template includes built-in modules such as exhibition scheduling, equipment displays, and case study collections, making it an excellent choice for exhibition organizers or equipment rental providers looking to acquire new customers and promote their brand. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password...
👁 41
Semiconductor Electronic Components Website Template 0103

Semiconductor Electronic Components Website Template 0103 Practical Collection Yiyou template

An eyouCMS website template designed specifically for semiconductor and electronic component manufacturers. Its modern, high-tech design is ideal for showcasing semiconductor products, electronic components, and technical solutions. This template helps semiconductor companies present their products online and attract customers from the electronics industry. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for YouYouCMS | YouYouCMS...
👁 45
(Adaptive Mobile Version) pbootCMS Marketing-Oriented Mechanical Bearing Industrial Website Template – Responsive Hardware and Machinery Enterprise Website Source Code Download: 0656

(Adaptive Mobile Version) pbootCMS Marketing-Oriented Mechanical Bearing Industrial Website Template – Responsive Hardware and Machinery Enterprise Website Source Code Download: 0656 Practical Collection pbootcms Template

A marketing-oriented mechanical bearing and hardware machinery PbootCMS responsive corporate website template, compatible with both PC and WAP devices. The professional and sophisticated design focuses on product showcasing and brand identity building. It enables machinery manufacturing enterprises to showcase their product ranges online and attract targeted customer inquiries. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5....
👁 61