【发布时间】:2019-03-24 14:10:09
【问题描述】:
我的 CSS:
#container {
position: center;
margin-top: 80px;
z-index: 950;
{block:IfGridTheme}margin-left: 430px;{/block:IfGridTheme}
{block:IfNotGridTheme}margin-left: 435px;{/block:IfNotGridTheme}
}
.entry {
position: justify;
font-size: 12px;
color: {color:Body Text};
font-family: roboto condensed;
letter-spacing: 1px;
{block:PermalinkPage}width: 1000px;
margin-top: 15px;{/block:PermalinkPage}
word-wrap: break-word;
margin-top: 45px;
}
#container1 {
white-space: nowrap;
border: none;
width: 100%;
margin-left: auto;
margin-right: auto;
}
#container1 > div {
background: none;
width: 100%;
height: 100%;
display: inline-block;
padding: 1% 5%;
margin-right: 176px;
}
.stretch {
width: 100%;
display: inline-block;
font-size: 0;
line-height: 0
}
以及我的特定类型页面的 HTML:
<div id="container1">
<div>
<div class="picture_holder" style="width: 1080px;">
<div class="picture" style="width: 1080px;"><img alt="LINKTOFIRSTIMAGE" height="575" src="LINKTOFIRSTIMAGE" />
<div class="captioning">
<div class="caption"><em>CAPTION</em></div>
</div>
</div>
</div>
</div>
<div>
<div class="picture_holder" style="width: 1080px;">
<div class="picture" style="width: 1080px;"><img alt="SECONDIMAGELINKANDSOFORTH" height="575" src="SECONDIMAGELINKANDSOFORTH" />
<div class="captioning">
<div class="caption"></div>
</div>
</div>
</div>
</div>
</div>
在给定页面上,一系列图像的高度、宽度和整体纵横比完全相同,它们之间的间距与1) 中的间距完全相同(尽管比我想要的宽很多)这张图:
...但是在一系列具有相同高度但宽度变化很大的图像中,间距与2) 中的间距非常接近。
我个人也不想要。如何更改我的代码,以便对于这两种类型的页面以及我计划创建的更多页面,每个 image 之间的间距在整个板上的像素数量完全相同网站?这些图像周围是否有一个假想的框导致问题?
编辑:我还应该声明我在网站 Tumblr.com 上使用 HTML 功能,因此 flex 等某些属性似乎永远不可用。
edit2: display: grid; 和类似的似乎也不可用。如果有帮助,这也位于代码的顶部:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
感谢您到目前为止提供的信息。
【问题讨论】:
-
你的实现是错误的。使用 css flex 就完成了。
-
怎么样?我在每个元素下使用
display: flex;进行了测试,但主要问题似乎是我正在使用的网站似乎无法识别“flex”,因为当我输入它时它没有突出显示为某种颜色其余的部分。与flex-wrap和flex-grow以及其他相同。 @RichardPariath -
Flex 应该在容器中使用,而不是在单个元素上使用。我写了一个简短的代码作为答案。也许这可以帮助