javascript - 画廊 - dl、dt、dd - 未正确显示

标签 javascript jquery html wordpress

在为问题设置标题时遇到一些问题。但问题是 3 列图库在以下浏览器中无法正确显示:

Windows:

  • 火狐浏览器

适用于 Chrome 和 Internett Explorer。

苹果机:

  • Chrome
  • Safari

尚未找到任何可以正常工作的浏览器。

该画廊使用基本的 WordPress 运行,因此它不是我开发的。因此它应该适用于所有平台?

不确定我应该从哪里开始寻找问题。

我尝试删除检查器中的一些图像,这是我发现的:

  • 8幅作品
  • 9 张图片不起作用
  • 10-11 张图片作品
  • 12-13 张图片不起作用

我还发现其他画廊工作正常。 Example .

我在下面添加了一些 HTML,所以您可能会发现一个错误。 Demo对于这个问题。

<div id='gallery-2' class='gallery galleryid-1349 gallery-columns-3 gallery-size-thumbnail'>
    <dl class='gallery-item'>
        <dt class='gallery-icon portrait'>
            <a href='http://annettemartens.com/wp-content/uploads/2013/08/IMG_22574.jpg' data-rel="lightbox-gallery-2"><img width="300" height="300" src="http://annettemartens.com/wp-content/uploads/2013/08/IMG_22574-300x300.jpg" class="attachment-thumbnail size-thumbnail" alt="The Joy of Life" aria-describedby="gallery-2-680" srcset="http://annettemartens.com/wp-content/uploads/2013/08/IMG_22574-300x300.jpg 300w, http://annettemartens.com/wp-content/uploads/2013/08/IMG_22574-768x768.jpg 768w, http://annettemartens.com/wp-content/uploads/2013/08/IMG_22574-1024x1024.jpg 1024w" sizes="(max-width: 300px) 100vw, 300px" /></a>
        </dt>
        <dd class='wp-caption-text gallery-caption' id='gallery-2-680'>
            Title
        </dd>
    </dl>
    <dl class='gallery-item'>
        <dt class='gallery-icon portrait'>
            <a href='http://annettemartens.com/wp-content/uploads/2013/08/IMG_3772.jpg' data-rel="lightbox-gallery-2"><img width="300" height="300" src="http://annettemartens.com/wp-content/uploads/2013/08/IMG_3772-300x300.jpg" class="attachment-thumbnail size-thumbnail" alt="Abandoned Garden I" aria-describedby="gallery-2-448" /></a>
        </dt>
        <dd class='wp-caption-text gallery-caption' id='gallery-2-448'>
            Title
        </dd>
    </dl>
    <dl class='gallery-item'>
        <dt class='gallery-icon landscape'>
            <a href='http://annettemartens.com/wp-content/uploads/2013/08/IMG_30962.jpg' data-rel="lightbox-gallery-2"><img width="300" height="300" src="http://annettemartens.com/wp-content/uploads/2013/08/IMG_30962-300x300.jpg" class="attachment-thumbnail size-thumbnail" alt="Celestian Visitant" aria-describedby="gallery-2-955" /></a>
        </dt>
        <dd class='wp-caption-text gallery-caption' id='gallery-2-955'>
            Title
        </dd>
    </dl>
    <br style="clear: both" />
    <!-- And so on  -->
</div>

enter image description here

有什么想法吗?

最佳答案

当你有不同高度的 float 元素时,就会发生这种情况:

#wrapper {
  width: 400px;
  border: 1px solid blue;
  overflow: hidden;
}
.item {
  width: 198px;
  height: 198px;
  border: 1px solid;
  float: left;
  background: yellow;
}
.item:first-child {
  height: 210px;
}
<div id="wrapper">
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
</div>

避免这种情况的一种方法是在每行之后使用间隙。看来您已经在使用 br 来实现这一点。

#wrapper {
  width: 400px;
  border: 1px solid blue;
  overflow: hidden;
}
.item {
  width: 198px;
  height: 198px;
  border: 1px solid;
  float: left;
  background: yellow;
}
.item:first-child {
  height: 210px;
}
#wrapper > br {
 clear: left;
}
<div id="wrapper">
  <div class="item"></div>
  <div class="item"></div>
  <br />
  <div class="item"></div>
  <div class="item"></div>
</div>

问题是您的 br 未显示,因为

.gallery br {
  display: none;
}

那么他们就无法清除。只需删除该样式,或者不使用 float 。

关于javascript - 画廊 - dl、dt、dd - 未正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38062251/

相关文章:

javascript - 带有 location.href 和 document.referrer 的 Html 按钮

php - javascript 中的 sprintf url 格式

javascript - 不再支持用于完全可定制的 HTML Twitter 提要的 twitter_update_list 脚本?

javascript - 使用 d3js 的词云

javascript - 从在javascript中创建的id触发jquery事件

javascript - 如果 'this' 类为 true,则禁用按钮

javascript - Array.prototype.slice.call(arguments) 与 Array.prototype.slice.apply(arguments)

javascript - 在队列中制作 jQuery 动画

javascript - jquery 通过一个元素的单击或另一个元素的按键(输入)触发函数

java - 为什么 JSON 中的汉字导致 JSON.parse 出现 "bad control character"错误?