首页 \ 问答 \ 用css / js响应重叠图像(Rsponsive overlapping image with css/js)

用css / js响应重叠图像(Rsponsive overlapping image with css/js)

我有一个全格div的图像,它与div重叠,所以当浏览器被调整大小时,会显示/隐藏更多图像,但图像本身不会调整大小。 我得到了它的宽度工作,但我怎么能达到相同的效果的高度?

这是我的测试: https//jsfiddle.net/g8h8umt3/

我得到了与CSS工作的宽度:

#img-header{
    margin-left: 50%;
    transform: translateX(-50%);
}

编辑:

这是一个关于它如何工作的图像图像

背景中的图像应保持其大小,并且根据屏幕大小,父div应该变得更小/更大。 我得到了宽度的行为,但我不知道如何去做图像的高度。

我也试过添加

#img-header{
    margin-top: 50%;
    margin-left: 50%;
    transform: translate(-50%,-50%);
}

但这似乎并不奏效


I have a image in a fullwidth div which is overlapping the div, so when the browser gets resized more of the image is shown/hidden but the image itself does not get resized. i got it working for the width but how can i achieve the same effect for the height?

Here is my test: https://jsfiddle.net/g8h8umt3/

i got the width working with css:

#img-header{
    margin-left: 50%;
    transform: translateX(-50%);
}

EDIT:

Here is a image on how it suppose to work: Image

The image in the background should keep its size and the parent div should get smaller/larger depending on the screen size. I got the behaviour for the width but i dont know how to do it for the height of the image.

I also tried adding

#img-header{
    margin-top: 50%;
    margin-left: 50%;
    transform: translate(-50%,-50%);
}

but this does not seem to work


原文:https://stackoverflow.com/questions/45495266
更新时间:2022-03-17 17:03

最满意答案

在我的日常生活中,我只是为角色创建一个动画,而在Unity中我是父亲的武器,例如手骨。 这种简单的方法对我来说很好。 并尝试将您的模型导出为.fbx,通常更好。


On my daily basis, I just create an animation for character, and in Unity I am parent a weapon to the, for example, hand bone. This simple approach works fine for me. And try exporting your model as .fbx, usually its better.

相关问答

更多
  • 在我的日常生活中,我只是为角色创建一个动画,而在Unity中我是父亲的武器,例如手骨。 这种简单的方法对我来说很好。 并尝试将您的模型导出为.fbx,通常更好。 On my daily basis, I just create an animation for character, and in Unity I am parent a weapon to the, for example, hand bone. This simple approach works fine for me. And try ...
  • 您是否探索过Unity中可用的2D Sprite引擎? 无论谁说“Unity不是真正的设计用于2D工作的引擎”,他们正在谈论这个问题。 我刚开始研究爱好2D游戏,并使用名为Orthello的Unity插件( 请参阅WyrmTale网站获取信息 )。 它可以处理精灵表,动画,碰撞检测等等,而无需编写大量代码来完成此操作。 学习曲线有点陡峭,他们网站上的例子并不是最好的,但我发现复制下载附带的示例解决方案是获得某些工作的最佳方式。 还有一个名为Sprite Manager 2的类似工具,但您必须为此付费(我认为 ...
  • 在UV解开你的模型后,你将uv保存在一个文件中,你应该将该文件作为一个纹理应用于你的模型,你将会完成,告诉我你是否已经这样做了。 这是有用的教程。 after you UV unwrapped your model you save the uv in a file in blender you should apply that file as a texture to your model in unity and you will be done,tell me if you have already ...
  • 您可以使用不同的图层和蒙版来混合多个动画。 你可以看看这里: https://www.youtube.com/watch?v=-SAnr8-Xfgg 头像面具的Unity教程: https://unity3d.com/learn/tutorials/topics/animation/avatar-masks You can use different layers and masks to blend multiple animations. You can have a look at here: htt ...
  • 这取决于你的游戏是什么,以及什么样的规模。 与其他动态选项交互的下降对象? 物理学通常是最好的答案。 只是想要一些东西离开屏幕然后消失? 动画可以有意义,但是没有使用物理也有其他选择。 使用大量的对象? 物理学是处理它的好方法。 使用数千个对象? 物理学可能太多,需要考虑其他方式。 你的问题真的很模糊,所以除了模糊的回答之外别无他法。 但是,对于你的第一款游戏,我会说不要过于担心优化,一开始就要简单。 随着您的学习,您将了解以后可以修剪/更改的内容。 It depends a lot on what you ...
  • 如果你想像你说的那样滚动它,你可以通过几种方式实现这一点,而无需退出Unity。 例如,这里有一些: 在立方体中使用Animator组件并应用预制动画(通过动画窗口在Unity中制作,只需更改变换旋转属性) 使用物理学来施加恒定的旋转力(扭矩) 使用脚本来修改每个帧更新(c#或javascript)上的变换旋转属性 可能存在更多,但这些是最简单和最简单的。 如果我选择一个,Animator + Animations将是我的选择。 还要记住,当在场景中的多个实例(大量立方体)上使用时,此组件(Animator ...
  • Mecanim执行人形动画的重定向 ,因此对于特定情况的关注,您应该能够在不同模型上使用相同的装备和动画片段集。 对于抓住家具的问题,您不需要操纵物体。 您可以使用IK精确地将角色的手移向目标对象,然后将其父级添加到层次结构中的相对关节。 Mecanim performs retargeting of humanoid animations, so for what concern that specific case, you should be able to use the same rig and ...
  • 大家。 经过一个早晨的研究,我发现了一个完美解决我的问题的好视频。 ( https://www.youtube.com/watch?v=5GbDkqw0U9Y )事实上,问题来自于Blender的输入设计,它使用“duplivert”技术来构建模型。 everyone. After one more morning's research, I've found a great video that perfectly resolve my problem. (https://www.youtube.com/ ...
  • 发现你去: 文件/导出并选择 Found out you go to : FILE/Export and choose
  • 一种解决方案是在没有按下任何移动键时使其播放偶像动画。 if(Input.GetKey ("left")){ transform.position.x = transform.position.x - 0.1; animation.Play("walking"); } if(!Input.GetKey ("left")){ animation.Play("idle"); } 此外,动画师应该是动画。 One solution would be to make it play the idol anima ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)