进击的前端!


HTML

代表网站图标

一组 radio name名称一样,代表一组,每组只能选择一个;

加入selected表示默认;

CSS

行高可以使之竖直居中;

text-algin:center;

line-height:200px;

background-color:lightblue;

height:200px;

补上伪类元素:

.div-outer::before {
     content: "";
     display: table;
}
AcWing-WEB课2.3 17:28s

两个实例

B站小卡片(有一说一,b站卡片真的漂亮)




    
    
    
    bilibili
    
    


    
向日葵
哑巴湖水怪
58 关注 3 粉丝 15 赞
.user-card {
    width: 366px;
    height:239px;
    box-shadow: 2px 2px 5px lightgrey;
    border-radius: 5px;
}
.user-card-head {
    background-image: url(../static/images/back.png);
    background-size: cover;
    width: 100%;
    height: 85px;
}
.user-card-body {
    width: 366px;
    height: 154px;
    box-sizing: border-box;
}
.user-card-body-left {
    width: 70px;
    height: 100%;
    float: left;
    /* background-color: lightblue; */
}

.user-card-body-left > img {
    width:48px;
    height:48px;
    border-radius: 50%;
    margin: 10px 9px;
}
.user-card-body-right {
    width: 266px;
    height: 126px;
    float: left;
    /* background-color: lightgreen; */
    padding: 12px 20px 16px 10px;
}
.user-card-body-right-text {
    width: 100%;
    height: 96px;
}
.user-card-body-right-text-username {
    font-size: 16px;
    color: #222222;
    font-weight: bold;
}
.user-card-body-right-text-reputation {
    margin-top: 12px;
}
.user-card-body-right-text-reputation-item  {
    margin-right: 20px;
}
.user-card-body-right-text-reputation-item > span:nth-child(1) {
    font-size: 12px;
    color: #222222;
}
.user-card-body-right-text-reputation-item > span:nth-child(2) {
    font-size: 12px;
    color: #242b35;
}
.user-card-body-right-button > button:nth-child(1) {
    margin: 0 8px 0 0;
    background-color: #00AEEC;
    color: white;
    width: 100px;
    height: 30px;
    border-radius:5px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: 700ms;
}
.user-card-body-right-button > button:nth-child(2) {
    width: 102px;
    height: 32px;
    font-size: 14px;
    color: #61666D;
    border: grey solid 1px;
    cursor: pointer;
    border-radius: 5px;
    transition: 700ms;
}
.user-card-body-right-button > button:nth-child(2):hover {
    border-color: #00B5E5;
    color: #00B5E5;
}


导航栏

效果图:




    
    
    
    立体导航栏
    


    
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.container {
    background-color: #ffbdc9;
    width: 100%;
    height: 100vh;
    /* display: flex; */
    text-align: center;
    margin: 0 auto;
    /* 竖直居中 */
    /* align-items: center; */
    /* 水平居中 */
    /* justify-content: center; */
}
nav {
    background-color: #fff;
    border-radius: 50px;
    padding: 10px;
    /* 阴影效果 */
    box-shadow: 0 25px 20px -20px rgba(0,0,0,0.4);

}
nav ul li {
    /* 去掉li的小黑点 */
    list-style: none;
    padding: 13px 15px;
    margin: 10px;
    /* 改成inline-block之后就是成行 */
    display: inline-block;
    font-size: 18px;
    font-weight: 500;
    color: #777;
    cursor: pointer;
    position: relative;
    z-index: 2;
    /* transition: color 0.5s; */
}
nav ul li::after {
    content: "";
    background: #f44566;
    width: 100%;
    height: 100%;
    border-radius: 30px;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: -1;
    opacity: 0;
    transition: top 0.5s,opacity 0.5s;
}
nav ul li:hover {
    color: rgb(231, 231, 226);
}
nav ul li:hover::after {
    top: 50%;
    opacity: 1;
}