gpt4 book ai didi

css - 我希望我的(英雄)图像在屏幕尺寸变小时裁剪

转载 作者:行者123 更新时间:2023-11-28 02:46:32 24 4
gpt4 key购买 nike

我正在尝试制作一个网站,但我遇到了一个问题。我有一张图片,我需要它始终填满整个屏幕。就像他们在这个网站上所做的那样:http://mollyandmepecans.com这是我的网站:https://mountainweb-cemre2002.c9users.io/Homepage.html

谢谢!

最佳答案

删除图像元素,然后添加此 CSS:

body {
background-image: url("MountEverest.png");
background-position: center;
background-repeat: no-repeat;
background-size:cover;
}

或者,如果您不想使用背景,请将其添加到您的 HTML 中以替换您的图像元素:

<div class="hero"></div>

这是你的 CSS:

.hero {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: -100;

background-image: url("MountEverest.png");
background-position: center;
background-repeat: no-repeat;
background-size:cover;
}

关于css - 我希望我的(英雄)图像在屏幕尺寸变小时裁剪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46902767/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com