【问题标题】:Image height to the other div图像高度到另一个 div
【发布时间】:2015-01-18 21:51:43
【问题描述】:

我是 Stackoverflow 的新手,我需要帮助解决这些问题。

所以问题是:我希望这个虚线图像高度达到容器的 100%。

HTML

<div id="test1">

</div>

<aside>
    <?php
    if (logged_in() === true) {
        include 'includes/widgets/loggedin.php';
    } else {
        include 'includes/widgets/login.php';
    }
    include 'includes/widgets/user_count.php';
    include 'includes/widgets/sponsors.php';
    include 'includes/widgets/partners.php';

    ?>
</aside>

CSS

aside {
    width:260px;
    float:right;
    background-image:url(../images/dashed.png);
    background-repeat: repeat-y;
    padding-left:15px;
}

#container, footer {
    background:#fff;
    width:1100px;
    margin:0 auto;
    padding:20px;
}

#test1 {
height:1000px;
}

谁能帮帮我?

【问题讨论】:

  • 你知道 CSS 上有一个 border dashed 属性吗?
  • 我们需要有关您的 html 的更多详细信息。显然,您的“旁边”与“#container”的高度不同。
  • @Danko 确实有一个虚线边框,但它不适用于 height:100%;和高度:自动;它只适用于图像,所以我尝试了但我仍然不会出来。
  • @Diego 我已经编辑过了,可以吗?
  • 但是...标记中的#container 在哪里?,如果#test1 的高度在#container 中是相同的,那么你应该将高度设置为#test1 (1000px)。否则,如果高度发生动态变化,您可以使用此脚本: document.querySelector("aside").style.height = document.querySelector("#container").offsetHeight + 'px';

标签: html css image height


【解决方案1】:

试试这个:

aside { 
  background: url(images/bg.jpg) repeat-y center center fixed; 
  padding-left:15px;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

【讨论】:

  • 它不工作,我试过了,我用灰色背景搁置了。身高还是一样的问题截图:nl.tinypic.com/r/fa7x1e/8
  • @BartvanderHoeven 如果您在问题中包含所有代码或制作小提琴,则更好 - codepen 重现问题而不是附加一百个 img
  • 好的,抱歉。我会做jsfiddle
猜你喜欢
  • 2015-12-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-13
  • 1970-01-01
  • 1970-01-01
  • 2014-05-22
  • 2014-06-22
相关资源
最近更新 更多