如何使 li 标签水平,而它是一个块

how to make a li tag horizontal while its a block

我想用 html/css/js 制作一个在线纸牌游戏,我想创建一个显示所有纸牌的地方,但我希望它们是内联和内联块,因为我需要给它一个自定义宽度和高度但是当我这样做时它不起作用

代码如下:

var players = 
[
    {
        "id":1,
        "name":"messi",
        "price":100

    },
    {
        "id":2,
        "name":"ronaldo",
        "price":100

    }
];

for (var i = 0; i<players.length; i++){
    document.getElementById('cards').innerHTML += `<li><div class="card" style="background-image: url('images/${players[i].name}.png');background-size: 80px 110px;"><h1>${players[i].name}</h1></div></li>`;
}
.coin{
    display: inline-block;
    margin-top: 5px;
    margin-left: 10px;
    text-align: center;
    width: 25px;
    height: 25px;
    background-color: gold;
    border-radius: 50%;
    box-shadow: 0 0 10px goldenrod;
}

.xp{
    display: inline-block;
    margin-top: 5px;
    margin-left: 10px;
    text-align: center;
    width: 25px;
    height: 25px;
    background-color: darkblue;
    border-radius: 50%;
    box-shadow: 0 0 10px blue;
}

.navbar{
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
}
  
.nav-item {
    float: left;
}
  
.nav-item a {
    display: block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

.card{
    display: inline-block;
    width: 80px;
    text-align: center;
    height: 110px;
    border-radius: 5px;
    margin: 5px;
    color: #fff;
    font-size: 12px;
    box-shadow: 0 0 5px black;
}

.cards{
    list-style-type: none;
    display: inline;
    background-color: rgb(56, 56, 56);
    padding: 5px;
    margin: 20px;
    border-radius: 5px;
}

* {
    font-family: "Helvetica Neue",Helvetica,Arial;
}
<!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">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
    <script src="script.js" defer></script>
</head>
<body style="background-color: rgb(53, 53, 53);">
    <ul class="navbar">
        <li class="nav-item"><div class="coin" >0</div></li>
        <li class="nav-item"><div class="xp">0</div></li>
        <li class="nav-item" style="float:right"><a>EFOOTBALL</a></li>
    </ul>

    <ul class="cards" id="cards">
        
    </ul>
</body>
</html>

如果您 运行 片段不是水平的 请帮助我,我需要快速帮助

而不是 inline 你应该做到 display: flex

编辑: 使卡片转到下一行使用 flex-wrap: wrap

var players = 
[
    {
        "id":1,
        "name":"messi",
        "price":100

    },
    {
        "id":2,
        "name":"ronaldo",
        "price":100

    }
];

for (var i = 0; i<players.length; i++){
    document.getElementById('cards').innerHTML += `<li><div class="card" style="background-image: url('images/${players[i].name}.png');background-size: 80px 110px;"><h1>${players[i].name}</h1></div></li>`;
}
.coin{
    display: inline-block;
    margin-top: 5px;
    margin-left: 10px;
    text-align: center;
    width: 25px;
    height: 25px;
    background-color: gold;
    border-radius: 50%;
    box-shadow: 0 0 10px goldenrod;
}

.xp{
    display: inline-block;
    margin-top: 5px;
    margin-left: 10px;
    text-align: center;
    width: 25px;
    height: 25px;
    background-color: darkblue;
    border-radius: 50%;
    box-shadow: 0 0 10px blue;
}

.navbar{
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
}
  
.nav-item {
    float: left;
}
  
.nav-item a {
    display: block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

.card{
    display: block;
    width: 80px;
    text-align: center;
    height: 110px;
    border-radius: 5px;
    margin: 5px;
    color: #fff;
    font-size: 12px;
    box-shadow: 0 0 5px black;
}

.cards{
    list-style-type: none;
    display: flex;
    flex-wrap: wrap;
    background-color: rgb(56, 56, 56);
    padding: 5px;
    margin: 20px;
    border-radius: 5px;
}

* {
    font-family: "Helvetica Neue",Helvetica,Arial;
}
<!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">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
    <script src="script.js" defer></script>
</head>
<body style="background-color: rgb(53, 53, 53);">
    <ul class="navbar">
        <li class="nav-item"><div class="coin" >0</div></li>
        <li class="nav-item"><div class="xp">0</div></li>
        <li class="nav-item" style="float:right"><a>EFOOTBALL</a></li>
    </ul>

    <ul class="cards" id="cards">
        
    </ul>
</body>
</html>