gpt4 book ai didi

html - 如何在不失去响应能力的情况下使背景图像正确适合板内

转载 作者:搜寻专家 更新时间:2023-10-31 22:53:10 25 4
gpt4 key购买 nike

我有代码,其中有类框,我已将 backgroundimageclass box box1

我的问题图像没有正确地放入板中

当我重新调整窗口时,它向上移动

如何改正。

如何使图像正确地适合板内 而不失去响应能力

这是执行此操作的方法,当我尝试使其适合板内时,它不仅适合盒子内,而且还失去了响应能力..

当它尝试调整窗口大小时图像向上移动..

html, body {
background-image:url(https://i.ibb.co/K7mpxZG/background9.jpg);
background-repeat: no-repeat;
background-size: cover;
width:100%;
height:100%;
overflow: hidden;
background-size: 100vw 100vh;
}

#box1 {
position: absolute;
top: 55.3vh;
left: -19.98vw;
cursor: pointer;
border:px solid #0066CC;
background-repeat: no-repeat;
background-size: cover;
}

#box1 p {
width: 10.0vw;
height: 1.0vh;
border-radius: 25%;
}


#container {
white-space: nowrap;
border:px solid #CC0000;
}

.containerr {
border: px solid #FF3399;
}

.container2 {
width: 50.1vw;
position: fixed;
top: 10.5vh;
left: 30.5vw;
}

.box p {
font-size: calc(2vw + 10px);
}


.hidden{
visibility: hidden;
}

p {
font: "Courier New", Courier, monospace;
font-size: 5vw;
color: blue;
text-align: center;
}
<div class="container2">
<div class="containerr">
<div class="pic" id="content">
<div id="container">

<div class="box box1" id="box1" style="background-image:url(https://picsum.photos/200/300);">
<p name="values" id="name1" class="hidden"></p>
</div>

</div>
</div>
</div>

最佳答案

我认为你处理这个问题的方式是错误的。相反,我会从主背景中提取 board 元素并将其单独用作一个元素:

html {
background: #afffdc;
}

#container {
position: fixed;
bottom: 0;
left: 100px;
background: url(/image/CM15R.jpg) top/contain no-repeat;
height: 50vh;
width: 29vh;
max-width: 20vw;
max-height: 35vw;
}

.box {
padding-top: 173%;
background: url(https://picsum.photos/200/300) 50% 5%/86% 27% no-repeat;
}
<div id="container">
<div class="box">
</div>
</div>

更新

这里是透明版

html {
background: linear-gradient(to right,pink, lightblue);
}

#container {
position: fixed;
bottom: 0;
left: 100px;
background: url(/image/ctB0T.png) top/contain no-repeat;
height: 50vh;
width: 29vh;
max-width: 20vw;
max-height: 35vw;
}

.box {
padding-top: 173%;
background: url(https://picsum.photos/200/300) 50% 5%/86% 27% no-repeat;
}
<div id="container">
<div class="box">
</div>
</div>

关于html - 如何在不失去响应能力的情况下使背景图像正确适合板内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54229422/

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