html - 我无法在 Bootstrap DIV 的底部获取图像

标签 html css twitter-bootstrap

我无法将图像放到 DIV 的底部(这可能是导致问题的 boostrap DIV)

<section id="page-portfolio">
    <div class="portfolio-item" id="item-1">
         <div class="col-sm-12 col-md-10">
             <img src="img/mac-devices-small.png" class="img-responsive"/>
         </div>
    </div>

    <div class="portfolio-item" id="item-2">
         <div class="col-sm-12 col-md-10">
             <img src="img/mac-devices-small.png" class="img-responsive"/>
         </div>
    </div>
</section>

CSS:

#page-portfolio {
  height: 1300px;
}

.portfolio-item {
   height: 45%;
   width: 100%;
}

#item-1 {
   background-image: url("../img/client-fb.jpg");
   background-size: cover;
   background-position: top;
   position: relative;
}

#item-1 img {
   position: absolute;
   bottom: 0;
}

有什么解决方法吗?

最佳答案

您的 div 元素的 id 为“item-2”,但您的选择器的目标是 #item-1。将您的 CSS 选择器更改为:

#item-1, #item-2 { ... }
#item-1 img, #item-2 img { ... }

或者:

.portfolio-item img { ... }

关于html - 我无法在 Bootstrap DIV 的底部获取图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21984074/

相关文章:

javascript - 将 div 制作成链接的最佳做法是什么?

css - Chrome 浏览器 - 绝对定位和 float 问题

html - 边框图像和 CSS 图像仅在 Firefox 中不对齐

javascript - Bootstrap 3 轮播无法正确加载/显示

jquery - 从外部 URL Bootstrap 加载选项卡

jquery - 将固定的 div 向上滑动并离开屏幕

javascript - 如何在失去焦点后立即验证字段

javascript - Bootstrap youtube 视频模式自动播放

html - 在 youtube iframe 上覆盖不透明的 div

html - 当浏览器宽度变小时,文本显示为两行