gpt4 book ai didi

css - 如何缩小背景图片的大小?

转载 作者:太空宇宙 更新时间:2023-11-03 23:14:52 28 4
gpt4 key购买 nike

我有一张图片尺寸:240px/240px。此图片尺寸只能在宽屏上使用,在移动设备上此图片必须为 80px/80px。我曾经尝试过的:

.picture{
height:100%;
min-height: 240px;
background: url("../../img/picture.png") no-repeat;
background-size: cover;
background-position: 50% 50%;
}
@media screen and (max-width: 480px) .picture {
height: 80px;
transform:scale(.3);
}

但是这个scale parents block,bg scaled wrong,完全正确,但这不是我需要的。这只是裁剪背景图片。

最佳答案

如果您尝试设置固定背景图片,这是缩放和对齐背景图片的示例:

.pic-wrap {
display: block;
height: 296px;
background-image: url(https://pbs.twimg.com/profile_images/590966305248784384/1gX6-SY6_400x400.jpg);
background-size: 256px;
background-position: 20px 50%;
background-repeat: no-repeat;
padding-left: 296px;
border: 1px solid #ddd;
}

@media only screen and (max-width: 320px) {
.pic-wrap {
background-size: 96px;
height: 126px;
padding-left: 126px;
}
}
<div class="pic-wrap">
<span class="label">Test</span>
</div>

关于css - 如何缩小背景图片的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30978614/

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