0
点赞
收藏
分享

微信扫一扫

【CSS】自定义平台文章封面图

小a草 2023-01-16 阅读 94


前言

Hello!小伙伴!
非常感谢您阅读海轰的文章,倘若文中有错误的地方,欢迎您指出~
 
自我介绍 ଘ(੭ˊᵕˋ)੭
昵称:海轰
标签:程序猿|C++选手|学生
简介:因C语言结识编程,随后转入计算机专业,有幸拿过国奖、省奖等,已保研。目前正在学习C++/Linux(真的真的太难了~)
学习经验:扎实基础 + 多做笔记 + 多敲代码 + 多思考 + 学好英语!

效果展示

【CSS】自定义平台文章封面图_css


【CSS】自定义平台文章封面图_程序猿_02

Demo代码

HTML

<!DOCTYPE html>
<html lang="en">

<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="style.css">
<title>Document</title>
</head>

<body>
<section>
<!-- 样式1 -->
<span>
<div class="title">PTA习题集</div>
</span>
<!-- 样式2 -->
<!-- <span>Haihong <p style="color:#ed5a65">P</p> <p style="color:#fdcb6e">r</p> <p style="color:#5698c3">o</p> </span> -->
</section>
</body>
</html>

CSS

html, body {
margin: 0;
height: 100%;
}

body {
display: flex;
justify-content: center;
align-items: center;
background-color: #f0a1a8;
}

section {
width: 650px;
height: 300px;
padding: 10px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
/* border-radius: 20px; */
border: 2px solid white;
overflow: hidden;
}

span {
position: relative;
width: 400px;
height: 220px;
border-radius: 20px;
border: 16px solid white;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 48px;
font-weight: 600;
letter-spacing: 3px;
font-family: sans-serif;
/* background-color: #fff; */
}

span::before {
content: 'Python';
width: 150px;
height: 150px;
border-radius: 2px;
text-align: center;
line-height: 250px;
background-color: #f7d794;
position: absolute;
top: -75px;
right: -75px;
transform: translate(50%, -50%);
font-size: 22px;
font-weight: 800;
font-family: sans-serif;
color: white;
transform: rotate(45deg);
}

span::after {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: 10px solid white;
border-radius: 20px;
}
.title{
position: relative;
/* background-color: #fff; */
display: flex;
align-items: center;
justify-content: center;
/* width: 100px; */
/* border-top:10px solid white; ; */
/* border-bottom: 10px solid white; */
border-radius: 10px;
}
.title::after{
content: '';
width: 100px;
height: 10px;
position: absolute;
background-color: white;
top: 110%;
border-radius: 10px;
}

结语

希望对您有所帮助,如有错误欢迎小伙伴指正~

我是 海轰ଘ(੭ˊᵕˋ)੭


【CSS】自定义平台文章封面图_html_03


举报

相关推荐

0 条评论