0

这个 Wordpress 主题中,我将使用不同高度的图像。所以,我正在尝试(使用 Firefox 的“检查元素”来测试)修改 css 以使 div 的高度随着图像高度的增加而增长。

通过检查图像元素,我们可以看到 a 中的图像<a>,即a 中的图像<div>

<article id="post-81" class="post-81 post type-post status-publish format-image hentry category-artwork category-photos category-writing tag-panache">

    <header class="entry-header"> … </header>
    <!--

     .entry-header 

    -->
    <div class="entry-thumbnail">
        <a rel="bookmark" href="http://fontfoliodemo.wordpress.com/2011/07/07/jellyfish/">
            <span class="entry-format"> … </span>
            <img class="attachment-featured-home-small wp-post-image" width="282" height="211" title="Jellyfish" alt="Jellyfish" src="http://fontfoliodemo.files.wordpress.com/2011/07/img_0429.jpg?w=282&h=211&crop=1"></img>
        </a>
    </div>

</article>

但如果我将这 3 个元素设置为height:auto,则<div>计算值将为0px。为什么?跟<a>元素有关系吗?(在其他主题中似乎没有<a>保存图像的元素)

我用来测试的图像:

在此处输入图像描述

我试图看到这张图片的全高。

4

2 回答 2

1

<div>高度为零,因为它唯一的孩子是<a>,即position:absolute。您将其设置<div>height:auto使其仅与包含其孩子所需的高度一样高,但其唯一的孩子是绝对的,这些人的身高对他们的父母毫无意义。

如果您希望它<div>具有高度,<a>只需从锚点中删除位置,基于主题它不会提供任何好处。

于 2013-11-15T03:49:08.133 回答
0

您不能将高度设置为 100% 吗?

于 2013-11-15T03:47:36.877 回答