javascript - 如何在 100% 高度 div 中始终将背景图像保持在底部?

标签 javascript css

这个问题与这个How to fill the the available height on screen with the div for any height?有关

如何在 100% 高度 div 中始终将背景图像保持在底部? 我只想显示背景图片的特定部分?

enter image description here

最佳答案

Try this :

eg

html:

<div id='a'>
    <div id='b'></div>
</div>

CSS:

#a, html, body{
    height: 100%;
}
#a {
    width: 300px;
    background-color: #dde;
    border: 1px solid #99c;
    position:relative;
    overflow: hidden
}

#b {
    width: 50px; 
    height: 50px;
    background-color: #99c;
    border: 1px solid #54a;
    position: absolute;
    bottom: -25px;
    left: 125px;
}

您需要将 bg 图像实际添加到 b

关于javascript - 如何在 100% 高度 div 中始终将背景图像保持在底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7150034/

相关文章:

javascript - 如果用户使用视网膜设备,则替换背景图像以获得更高质量

javascript - 如何订购对象中的项目?

javascript - 检查一个 div 是否有 child

javascript - 禁用的按钮颜色在 IE9 中未正确呈现

css3气泡,1px的三 Angular 形

javascript - 在鼠标悬停时清除 setinterval 并在鼠标移开时恢复

javascript - 在 headless 服务器上运行时如何运行 angular-phonecat 教程测试

javascript - Jquery 子选择器与 .each

javascript - 使用 ng-repeat 打印 html 中的数组

javascript - 响应式 jQuery Canvas , Canvas 背景在窗口调整大小时消失