程序实现
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="grid.css" />
<link
rel="stylesheet"
href="//at.alicdn.com/t/c/font_3966538_ci591vv17xi.css"
/>
<title>热门推荐</title>
</head>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: rgb(240, 242, 245);
}
.main {
/* margin-top: 100px; */
width: 1200px;
/* outline: 1px solid; */
padding: 5px;
margin: 0 auto;
}
.header {
margin-top: 10px;
display: flex;
place-content: space-between;
}
.header .more {
background-color: rgb(236, 237, 242);
border-radius: 10px;
padding: 5px 15px;
font-size: smaller;
text-decoration: none;
color: rgb(153, 153, 153);
}
.header .more:hover {
background-color: red;
color: white;
}
img {
width: 100%;
border-radius: 5px 5px 0px 0px;
}
.courselist {
background-color: white;
overflow: hidden;
border-radius: 5px;
}
.main .row {
margin-top: 10px;
gap: 20px;
}
.main .row img:hover {
transform: scale(1.1);
transition: 0.3s;
}
.main .row .desc {
padding: 10px 10px;
}
.main .row .desc .course {
/* max-height限制最大高度,height设置容器高度 */
max-height: 50px;
overflow: hidden;
height: 60px;
}
.main .row .desc .course .level {
background-color: bisque;
color: red;
font-size: small;
padding: 3px 5px;
border-radius: 2px;
}
.main .row .desc .course .level.fresh {
background-color: #e0e8fc;
color: #298afd;
}
.main .row .desc .course .name {
text-decoration: none;
font-size: 16px;
color: black;
margin-left: 5px;
}
.main .row .desc .course .name:hover {
color: red;
}
.main .row .desc .details {
display: flex;
place-content: space-between;
margin-top: 15px;
color: lightgray;
font-size: small;
}
.main .row .desc .details .favorites {
text-decoration: none;
color: lightgray;
}
.main .row .desc .details .favorites .iconfont {
font-size: small;
}
</style>
<body>
<div class="main">
<div class="header">
<h2 class="title">热门推荐</h2>
<a href="" class="more">更多 ></a>
</div>
<div class="row">
<div class="courselist col-2">
<a href=""
><img
src="https://img.php.cn/upload/course/000/000/068/6250203a9746a798.jpg"
alt=""
/></a>
<div class="desc">
<div class="course">
<span class="level fresh">初级</span>
<a href="" class="name">小白拯救者: PHP7基础语法快速预览</a>
</div>
<div class="details">
<span class="num">88793次学习</span>
<a href="" class="favorites"
><span class="iconfont icon-favorites">收藏</span></a
>
</div>
</div>
</div>
<div class="courselist col-2">
<a href=""
><img
src="https://img.php.cn/upload/course/000/000/068/62b2ea11e0283309.png"
alt=""
/></a>
<div class="desc">
<div class="course">
<span class="level fresh">初级</span>
<a href="" class="name">php8,我来也</a>
</div>
<div class="details">
<span class="num">254947次学习</span>
<a href="" class="favorites"
><span class="iconfont icon-favorites">收藏</span></a
>
</div>
</div>
</div>
<div class="courselist col-2">
<a href=""
><img
src="https://img.php.cn/upload/course/000/000/068/62501e37b43c6107.jpg"
alt=""
/></a>
<div class="desc">
<div class="course">
<span class="level">中级</span>
<a href="" class="name">在线报名系统(移动端)实战【公益直播】</a>
</div>
<div class="details">
<span class="num">69013次学习</span>
<a href="" class="favorites"
><span class="iconfont icon-favorites">收藏</span></a
>
</div>
</div>
</div>
<div class="courselist col-2">
<a href=""
><img
src="https://img.php.cn/upload/course/000/000/068/6264eab6691cf422.jpg"
alt=""
/></a>
<div class="desc">
<div class="course">
<span class="level fresh">中级</span>
<a href="" class="name">vue 3.0全新实战课程(2021版)第一季</a>
</div>
<div class="details">
<span class="num">171270次学习</span>
<a href="" class="favorites"
><span class="iconfont icon-favorites">收藏</span></a
>
</div>
</div>
</div>
<div class="courselist col-2">
<a href=""
><img
src="https://img.php.cn/upload/course/000/000/048/6101014ce7756479.jpg"
alt=""
/></a>
<div class="desc">
<div class="course">
<span class="level fresh">初级</span>
<a href="" class="name">Uniapp简爱读书项目开发--第一季</a>
</div>
<div class="details">
<span class="num">112833次学习</span>
<a href="" class="favorites"
><span class="iconfont icon-favorites">收藏</span></a
>
</div>
</div>
</div>
</div>
<div class="row" style="margin-top: 30px">
<div class="courselist col-2">
<a href=""
><img
src="https://img.php.cn/upload/course/000/000/068/62fa13f903c00637.png"
alt=""
/></a>
<div class="desc">
<div class="course">
<span class="level fresh">初级</span>
<a href="" class="name"
>从PHP基础到ThinkPHP6实战(2022灭绝师妹力作)</a
>
</div>
<div class="details">
<span class="num">97830次学习</span>
<a href="" class="favorites">收藏</a>
</div>
</div>
</div>
<div class="courselist col-2">
<a href=""
><img
src="https://img.php.cn/upload/course/000/000/068/63b580b8ca752485.jpg"
alt=""
/></a>
<div class="desc">
<div class="course">
<span class="level fresh">初级</span>
<a href="" class="name">公益直播:2023,聊聊PHP创业那点事</a>
</div>
<div class="details">
<span class="num">2217次学习</span>
<a href="" class="favorites"
><span class="iconfont icon-favorites">收藏</span></a
>
</div>
</div>
</div>
<div class="courselist col-2">
<a href=""
><img
src="https://img.php.cn/upload/course/000/000/068/6413e7ac3ce52126.jpg"
alt=""
/></a>
<div class="desc">
<div class="course">
<span class="level">中级</span>
<a href="" class="name">Golang深入理解GPM模型</a>
</div>
<div class="details">
<span class="num">386次学习</span>
<a href="" class="favorites"
><span class="iconfont icon-favorites">收藏</span></a
>
</div>
</div>
</div>
<div class="courselist col-2">
<a href=""
><img
src="https://img.php.cn/upload/course/000/000/068/6405f30155257902.jpg"
alt=""
/></a>
<div class="desc">
<div class="course">
<span class="level fresh">初级</span>
<a href="" class="name">公益直播:PHP8,究竟有啥野心..!?</a>
</div>
<div class="details">
<span class="num">511次学习</span>
<a href="" class="favorites"
><span class="iconfont icon-favorites">收藏</span></a
>
</div>
</div>
</div>
<div class="courselist col-2">
<a href=""
><img
src="https://img.php.cn/upload/course/000/000/068/63ff173c79edd672.jpg"
alt=""
/></a>
<div class="desc">
<div class="course">
<span class="level">中级</span>
<a href="" class="name">Linux运维基础课程【全程干货详解】</a>
</div>
<div class="details">
<span class="num">3575次学习</span>
<a href="" class="favorites"
><span class="iconfont icon-favorites">收藏</span></a
>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
实现效果