惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
D
Docker
Microsoft Security Blog
Microsoft Security Blog
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
Vercel News
Vercel News
F
Fortinet All Blogs
B
Blog
Recent Announcements
Recent Announcements
A
About on SuperTechFans
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Visual Studio Blog
月光博客
月光博客

博客园 - 郎中令

锦衣夜行,AI乐园 Redis实战:用缓存为数据库减负(二) Redis初体验: 搭建与简单应用(一) .Net Core的SwaggerUI接口分类+固定路由 真实性编码:配置NLog日志+Seq分布式 防御性编码:手搓NLog日志+Seq分布式 对接Java所谓的DES加解密 人大金仓数据库转换 人大金仓踩坑指南 RSA加解密笔记 HTTPS请求笔记- SSL安全通道验证问题 .NetCore打包部署(DLL) 字典映射处理 SM4算法快速预览与Framework4.5版本对接 简易首页防暴力-字典计时器 vite运行打包前端-部署Linux 记一次线上数据库异常的协助排查 降本增笑:记一次首页并发白屏优化过程 solr 基础介绍以及踩坑日记
动态展示缩放背景图
郎中令 · 2023-09-26 · via 博客园 - 郎中令

           有时候在渲染用户上传的图片时,需要根据不同图片宽高进行展示 ,若固定宽高,则会对图片一定程度的拉伸,导致图片变形,此时直接根据relation  相对位置,使图片的框和背景框动态缩放, 宽则同宽,长则同长, 直接上效果图

                   

        .srcbox-img {
            border: 1px solid #ddd;
            border-radius: 4px;
            width: 225px;
            height: auto;
            padding: 4px;
            margin: -30px 0 10px 70px;
            position:relative;
        }

        .imgcss-img {
            width: 215px;
            height: auto;
        }
                    <div class="col-sm-4">
                        <div>

                            <div>
                                <label class="control-label required" style="display: inline;">弹框图片</label>
                            </div>
                            <div class="srcbox-img" style="margin-top: 10px; margin-left: -1px">
                                <img id="ImgId-img" class="imgcss-img" />
                            </div>
                            <small style="margin-left:0px;">图片类型说明: (png、jpg、bmp)</small><br>
                            <small style="margin-left:0px;">图片建议说明</small>
                        </div>
                    </div>