gpt4 book ai didi

css - 内联 block 没有按预期工作

转载 作者:太空宇宙 更新时间:2023-11-03 20:13:58 26 4
gpt4 key购买 nike

我想创建一个页面,其中包含大量固定宽度/高度的 div,当它们到达页面边缘时(从左到右)环绕。

首先,较小的 div 宽度/高度被忽略,因此它们重叠。

其次,div 在页面下方而不是跨越页面。

http://jsfiddle.net/beakie/3S465/

Example

谁能告诉我为什么(以及我需要做什么来解决这个问题)?

谢谢

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Store Name</title>

<style>
.item-container {
width: 1200px;
height: 1200px;
background-color: blue;
}

.item {
display: inline-block;
width: 200px;
height: 200px;
background-color: red;
border: 1px solid black;
}

.image {
width: 100px;
height: 100px;
background-color: green;
}

.name {
background-color: purple;
}

.quantity {
background-color: orange;
}
</style>
</head>
<body>
<div>
Store Name
</div>
<div class="item-container">
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
<div class="item">
<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />
<div class="name">Widget</div>
<div class="quantity">12</div>
</div>
</div>
</body>
</html>

最佳答案

问题如下:

<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/" />

自动关闭的 div 不存在!这应该写成:

<div class="image" style="/*background-image: url('Artwork/1159.jpg');*/"></div>

P.S:我会展示一个更新的 fiddle ,但该网站现在似乎已损坏。

关于css - 内联 block 没有按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25161461/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com