简体   繁体   English

调整窗口屏幕大小时图像跟随背景

[英]Image follow Background when resizing window screen

I am looking for a way to do the following:我正在寻找一种方法来执行以下操作:

I have two sections on my HTML page, the first has a background image property in its CSS class and also has a logo positioned in the bottom of this section and I have too a second section that is just a normal section with some text.我的 HTML 页面上有两个部分,第一个部分在其 CSS 类中有一个背景图像属性,并且在该部分的底部还有一个徽标,我还有第二个部分,它只是带有一些文本的普通部分。

This picture shows the currently structure that I am using.这张图片显示了我正在使用的当前结构。

If the window screen is resized, the logo image has to follow the background image and keep its position in the bottom of the image.如果调整窗口屏幕大小,徽标图像必须跟随背景图像并保持其在图像底部的位置。

网页结构

The last thing that I've tried:我尝试过的最后一件事:

 .background { background: url('../images/background-heroes.png') no-repeat; background-position: top center; background-size: 100% auto; position: fixed; width: 100%; height: 100%; } .background .logo { width: 20%; padding: 20% 0 5% 0; margin: 0 auto; } .background h1 { font-size: 3em; text-align: center; text-transform: uppercase; width: 100%; }
 <section class="background"> <div class="logo"> <img src="images/logo.png"> </div> <h1>LIVE YOUR OWN ANIME!</h1> </section>

Unfortunately this solution that I've pasted makes the second section disappear.不幸的是,我粘贴的这个解决方案使第二部分消失了。

This seems to be about what you are trying to accomplish:这似乎与您要完成的工作有关:

CSS CSS

.background-image {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

HTML HTML

<div class="background-image">
    <img class="logo">
</div>

<div class="another-section"></div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM