首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用html拟合图像

用html拟合图像
EN

Stack Overflow用户
提问于 2020-01-09 08:13:38
回答 4查看 133关注 0票数 0

如何在蓝色矩形中匹配图像?我试过调整图像的大小,但是图像会模糊。

下面是我的代码:

代码语言:javascript
复制
<body>
<div style="background-color:lightgrey; font-size:30px; display:inline-block;">

<!-- Text -->
Our PCBA products are used in the audio, communication, computer peripheral,<br> 
home electronics, and entertainment industries. As existing markets grow and new<br> 
ones emerge, SCOPE is constantly expanding its resources and capabilities to<br> 
meet its customers' new and current needs. SCOPE practices selective investment<br> 
in the best and latest in manufacturing equipment as it continues to strive for<br> 
excellence in the electronics industry to provide a truly cost effective one-stop<br>
manufacturing facility for high quality products and services.
<!-- ----------------------------------------------------------------------------- -->
</div>

<div style="display:inline-block; position:absolute; top:99px; left:1000px">
<img src="Company.jpg" style="width:60%;">
</div>

</body>
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2020-01-09 08:32:43

好了伙计们。用Hadi Mir的建议解决这个问题。必须使用“对象匹配;填充”。这是我使用的代码。

代码语言:javascript
复制
<img src="Company.jpg" style="width:535px; height:240px; object-fit: fill;">
票数 -1
EN

Stack Overflow用户

发布于 2020-01-09 08:16:11

像这样改变你的形象:

代码语言:javascript
复制
<img src="Company.jpg" style="width:100%; object-fit: cover;">
票数 2
EN

Stack Overflow用户

发布于 2020-01-09 08:27:19

您可以使用object-fit: cover;

CSS对象适配属性

用于指定如何调整或调整大小以适应其容器。

代码语言:javascript
复制
<div style="display: flex">
    <div style="background-color:lightgrey; font-size:30px; display:inline-block;">
       Our PCBA products are used in the audio, communication, computer peripheral....
    </div>
    <div style="height: 200px">
        <img src="Company.jpg" style="object-fit: cover; width: 100%; height: 200px">
    </div>
</div>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59659654

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档