英文:
Match complex background images
问题
Suppose you have a layout like this:
为了尽可能接近设计,有几种方法:
-
将拼贴(包括持手机的女人)保留为图像,并尽力将背景图像('waves'或'swooshes')对齐得恰到好处,知道屏幕的任何调整都可能会打乱一切。
-
将拼贴和swooshes合成为单个图像,并将其用作背景(似乎效果不佳)。
-
???
如何尽可能接近设计?
英文:
Suppose you have a layout like this:
To get a "pixel-perfect" match to the design, there are a couple of approaches:
-
Keep the collage (with the woman with the phone) as an image, and torment yourself as you try to get the background images (the 'waves' or 'swooshes') aligned just right, knowing that any resize of the screen will likely throw it all off
-
Turn the collage and swooshes into a single image and use that as the background (seems poor)
-
???
How do I match the design as closely as possible?
答案1
得分: 0
我会告诉你如何使这个工作。为此,我将使用Bootstrap来在小屏幕设备上优化它。
我将整个内容分成三个块:
- 包含HTML(左侧):管理业务文本和按钮
- 包含一个女士用手机的静态图像
- 具有波浪设计的背景图像
现在,获取一个div,并将波浪设计的背景图像应用于它。将内容和女士与图像分开放在各自的div中,每个div将包含其中的项目。现在,即使屏幕尺寸发生变化,它们仍将保持在位置上。
<div class="row m-0 p-0 main-parent-div" >
<div class="col-12 col-xs-6 p-0">
管理业务
</div>
<div class="col-12 col-xs-6 p-0 image-div">
<img src='image.jpg' alt='女士与手机' class="image" />
</div>
</div>
CSS:
.main-parent-div {
background-image: url('wavy-image.jpg');
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
}
/* 使用此来控制宽度和高度 */
.image-div {
width: 100%;
height: 100%;
object-fit: cover; /* 根据图像使用cover或contain */
}
/* 保持图像响应式 */
.image {
width: 100%;
height: auto;
}
英文:
I would tell you what I would do to make this work. For this I will use Bootstrap to make it better on small screen devices too.
I would divide this entire thing into three blocks.
- Contains the HTML (left side): Managing business text and buttons
- Contains a static image of the woman with the phone
- A background image with the wavy design.
Now take a div and apply the background image of the wavy design to it. Divide the content and woman with the image into separate divs that would hold each of the items. Now it will remain in the position, even though the screen size changes.
<div class="row m-0 p-0 main-parent-div" >
<div class="col-12 col-xs-6 p-0">
Managing Business
</div>
<div class="col-12 col-xs-6 p-0 image-div">
<img src='image.jpg' alt='woman with phone' class="image" />
</div>
</div>
CSS:
.main-parent-div {
background-image: url('wavy-image.jpg');
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
}
/* Use this to control width and height */
.image-div {
width: 100%;
height: 100%;
object-fit: cover; /* Or contain, depending on the image */
}
/* Will keep the image responsive */
.image {
width: 100%;
height: auto;
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论