首页 话题 小组 问答 好文 用户 我的社区 域名交易 唠叨

[分享]css世界杯梦幻阵容代码

发布于 2024-11-11 19:09:16
0
12

CSS世界杯梦幻阵容

.team {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.player {
    width: 200px;
    height: 300px;
    border: 1px solid #ccc;
    margin: 10px;
    position: relative;
}

.name {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 10px;
    text-align: center;
}

.player img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player:nth-child(1) .name,
.player:nth-child(11) .name {
    background-color: #f00;
}

.player:nth-child(2) .name,
.player:nth-child(12) .name {
    background-color: #0f0;
}

.player:nth-child(3) .name,
.player:nth-child(13) .name {
    background-color: #00f;
}

.player:nth-child(4) .name,
.player:nth-child(14) .name {
    background-color: #ff0;
}

.player:nth-child(5) .name,
.player:nth-child(15) .name {
    background-color: #f0f;
}

.player:nth-child(6) .name,
.player:nth-child(16) .name {
    background-color: #0ff;
}

.player:nth-child(7) .name,
.player:nth-child(17) .name {
    background-color: #333;
}

.player:nth-child(8) .name,
.player:nth-child(18) .name {
    background-color: #999;
}

.player:nth-child(9) .name,
.player:nth-child(19) .name {
    background-color: #c00;
}

.player:nth-child(10) .name,
.player:nth-child(20) .name {
    background-color: #0c0;
}

@media screen and (max-width: 768px) {
    .player {
        width: 150px;
        height: 225px;
    }
} 

这是一个由CSS代码构成的世界杯梦幻阵容展示。利用 Flex 布局将每个球员的信息(球员照片和球员姓名)排放在一个画面里,充分利用了 CSS 3 的各种性能实现了多种颜色背景的风格。这是一个充满创意的CSS实现例子,值得在自己的项目中应用。

评论
一个月内的热帖推荐
91云脑
Lv.1普通用户

62849

帖子

14

小组

291

积分

赞助商广告
站长交流