jquery - 底部原点固定的 CSS 定位和缩放图像

标签 jquery html css

我有几张背景图片,用于重建一个人沿着地平线的场景。我想让图像本身增长但保持在这个地平线/基线。

这是 html:

<body>
<div class="container-fluid">
    <div class="row foreground">
    <center>
        <img class="foreground" src="css/images/BandName.png" alt="Planet of the Abts">
        <img class="foreground" src="css/images/AlbumTitle.png" alt="Planet of the Abts">
    </center>
    </div>

    <img id="missSaturn" src="css/images/miss_Saturn.png" alt="">

    <div id="videoDiv">
        <iframe id="video" width="700" height="394" align="center" src="https://www.youtube.com/embed/qMlyymUYjEM" frameborder="0" allowfullscreen></iframe>
    </div>

</div>

这是 CSS:

html{
height:100%;
width:100%;}

body{
height:100%;
background:url(images/ground2.png) no-repeat,
    url(images/spaceBackground.jpg)no-repeat;
background-size: cover;
background-position:0 300px,0 0 ;}


iframe{
margin:0 auto;
box-shadow: 5px 5px yellow;
max-width: 100%;}

.container-fluid{
display: inline-block;
height: 100%;
width: 100%;
padding-left:0;
padding-right:0;}

#video {
display: block;
margin: 0 auto;
min-width:300px;
margin-top: 300px;
margin-bottom: 30px;}

.row{
margin: 0 auto;}

#missSaturn{
z-index:-1;
margin: 0 auto;
max-width:80%;
position:fixed;
transform-origin:bottom 50%;}

.foreground{
z-index: 100;}

@media all and (min-width:300px){
#missSaturn{
    top:30%;}}

@media all and (min-width:400px){
#missSaturn{
    top:200px;
    left:15%;}}

@media all and (min-width:600px){
#missSaturn{
    top:100px;}}

@media all and (min-width:800px){
#missSaturn{
    top:50px;}}

基本上这就是我想要实现的目标。随着浏览器/设备从左到右调整大小,图像会缩小,但其原点位于该基线。

我正在努力实现的目标的图片

horizon/baseline image background

我怎样才能做到这一点?

最佳答案

在您的 css id #missSaturn 中将 transform-origin:bottom 50% 切换为 transform-origin:50% bottom

关于jquery - 底部原点固定的 CSS 定位和缩放图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29736906/

相关文章:

javascript - 遍历列表并在 jQuery 为空时显示消息

javascript - 如何检测用户是否点击了 "back"按钮

html - 无法覆盖按钮的引导事件类

javascript - HTML/CSS 下拉导航菜单不显示

javascript - 如何从 vb.net 后面的代码读取在 jquery 中创建的 cookie?

javascript - jquery 检查字符串是否在字符串中

html - 当父级不在 : relative 位置时定位

javascript - 调整 flexbox 中图像的大小在 Chrome 中渲染不正确

html - 为什么我不能居中这个表格?

javascript - 当顶部 div 展开时向下移动 div