【页面布局】个人博客
背景介绍
很多人都有自己的博客,在博客上面用自己的方式去书写文章,用来记录生活,分享技术等。下面是蓝桥云课的博客,但是上面还缺少一些样式,需要大家去完善。
考试要求
解答:
index.css:
/* TODO:banner 上的文字 需要居中显示 */
.home-wrapper .banner .banner-conent .hero {
margin-top: 3rem;
text-align: center;
}
/* TODO: main-wrapper 通过设置main-wrapper 布局方式 让.main-left .main-right 正确显示 */
.main-wrapper {
margin: 1.5rem auto 0 auto;
max-width: 1100px;
padding: 0 0.9rem;
box-sizing: border-box;
position: relative;
display: flex;
justify-self: space-between;
}
/*/* TODO 宽度自适应 居左显示 */
.main-wrapper .main-left {}
/* 宽 245px 居右显示 */
.main-wrapper .main-right>* {
box-sizing: border-box;
width: 245px;
}
/* 以下代码不需要修改 */
.navbar .links {
padding-left: 1.5rem;
box-sizing: border-box;
white-space: nowrap;
font-size: 0.9rem;
position: absolute;
right: 1.5rem;
top: 0.7rem;
display: flex;
}
.nav-links .nav-item {
position: relative;
margin-left: 1.5rem;
line-height: 2rem;
color: var(--textColor);
display: inline-block;
}
.blogger-wrapper .avatar {
width: 100%;
overflow: hidden;
}
.card-box {
box-shadow: 0 1px 2px 0 rgb(0 0 0 / 10%);
transition: box-shadow 0.5s;
}
.blogger-wrapper .avatar img {
width: 100%;
height: 100%;
}
.banner {
background: rgb(17, 130, 182);
}
.theme-mode-dark {
--bodyBg: #27272b;
--mainBg: #1e1e22;
--sidebarBg: rgba(30, 30, 34, 0.8);
--blurBg: rgba(30, 30, 34, 0.8);
--textColor: #000000;
--textLightenColor: #0085ad;
--borderColor: #2c2c3a;
--codeBg: #252526;
--codeColor: #fff;
}
.theme-container {
color: var(--textColor);
min-height: 100vh;
}
.article-list .article-title {
border-bottom: 1px solid var(--borderColor);
font-size: 1.3rem;
padding: 1rem;
}
.nav-links .repo-link {
margin-left: 1.5rem;
color: var(--textColor);
}
.navbar a,
.navbar span,
.navbar img {
display: inline-block;
}
.nav-links a {
line-height: 1.4rem;
color: inherit;
}
.navbar .links .search-box {
flex: 0 0 auto;
vertical-align: top;
}
.search-box {
display: inline-block;
position: relative;
margin-right: 1rem;
}
.avbar {
padding: 0.7rem 1.5rem;
line-height: 2.2rem;
transition: transform 0.3s;
}
.navbar {
z-index: 20;
top: 0;
left: 0;
right: 0;
height: 3.6rem;
box-sizing: border-box;
box-shadow: 0 2px 5px rgb(0 0 0 / 6%);
}
body .search-box input {
background-color: transparent;
color: var(--textColor);
border: 1px solid var(--borderColor, #ccc);
}
.article-list .article-wrapper {
overflow: hidden;
}
.article-list .article-wrapper dl {
border-bottom: 1px dotted var(--borderColor);
float: left;
display: flex;
padding: 8px 0;
margin: 0;
height: 45px;
width: 100%;
}
header {
display: block;
}
.home-wrapper .banner {
width: 100%;
min-height: 450px;
color: #fff;
position: relative;
overflow: hidden;
}
.article-list .article-wrapper dl dt a {
color: var(--textColor);
flex: 1;
display: flex;
height: 45px;
align-items: center;
font-weight: normal;
}
.article-list .article-wrapper dl dt {
flex: 1;
display: flex;
}
.article-list .article-wrapper dl dd {
font-size: 1.1rem;
color: #f17229;
width: 50px;
text-align: center;
margin: 0;
line-height: 45px;
}
dd {
display: block;
margin-inline-start: 40px;
}
.article-list .article-wrapper dl dt .date {
width: 50px;
margin-right: 15px;
color: #999;
text-align: right;
font-size: 0.9rem;
line-height: 45px;
}
.search-box input {
cursor: text;
width: 10rem;
height: 2rem;
color: #4e6e8e;
display: inline-block;
border: 1px solid #cfd4db;
border-radius: 2rem;
font-size: 0.9rem;
line-height: 2rem;
padding: 0 0.5rem 0 2rem;
outline: none;
transition: all 0.2s ease;
}
a,
input,
button {
outline: none;
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
-webkit-focus-ring-color: rgba(0, 0, 0, 0);
}
.home-wrapper .main-wrapper {
margin-top: 2rem;
}
.home-wrapper .main-wrapper .main-left .card-box {
margin-bottom: 0.9rem;
}
.article-list {
padding: 1rem 2rem;
}
.main-wrapper .main-right .card-box {
margin: 0 0 0.9rem 0.9rem;
padding-top: 0.95rem;
padding-bottom: 0.95rem;
}
.blogger-wrapper {
height: auto;
display: inline-table;
padding-top: 0 !important;
overflow: hidden;
}
.categories-wrapper .categories {
margin-top: 0.6rem;
}
.categories-wrapper .categories a {
display: block;
padding: 8px 0.95rem 7px 0.95rem;
color: var(--textColor);
opacity: 0.8;
font-size: 0.95rem;
line-height: 0.95rem;
position: relative;
transition: all 0.2s;
border-left: 2px solid transparent;
margin-top: -1px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
a {
font-weight: 500;
color: #11a8cd;
text-decoration: none;
}
a,
input,
button {
outline: none;
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
-webkit-focus-ring-color: rgba(0, 0, 0, 0);
}
.categories-wrapper .categories a span {
float: right;
background-color: var(--textColor);
color: #fff;
border-radius: 8px;
padding: 0 0.13rem;
min-width: 1rem;
height: 1rem;
line-height: 1rem;
font-size: 0.6rem;
text-align: center;
opacity: 0.6;
transition: opacity 0.3s;
}
.blogger-wrapper .blogger {
padding: 0.3rem 0.95rem 0 0.95rem;
}
.blogger-wrapper .blogger .name {
font-size: 1.3rem;
display: block;
margin-bottom: 6px;
}
.blogger-wrapper .blogger .slogan {
color: var(--textColor);
}
.blogger-wrapper .blogger .name {
color: var(--textColor);
}
.categories-wrapper .title {
color: var(--textColor);
opacity: 0.9;
font-size: 1.2rem;
padding: 0 0.95rem;
}
.navbar {
padding: 0.7rem 1.5rem;
line-height: 2.2rem;
transition: transform 0.3s;
}
.navbar a,
.navbar img,
.navbar span {
display: inline-block;
}
题目有多种实现方法,以上仅供参考。