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

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

博客园 - Lee Vane

无法通过“控制面板”卸载 Office 2003、Office 2007 或 Office 2010 套件的情况下,如何才能将其卸载? 量子恒道统计-淘宝添加步骤 朋友写的,我觉得比较好,批量生产HTML中使用的 使用CSS设计了一个导航栏(仿康盛创想) 文章内容分页 可点击的下拉菜单 ASP多行多列显示代码- 5行 Formfieldhints.--表单提示效果 项目分享---google calendar.(日历,java版). asp根据出生时间判断生肖 ASP数据库操作类 新闻标题太长加省略号和对内容太长分页 检查组件是否已经安装,用Jmail组件发送邮件 格式化日期 ASP函数,实现多个功能的弹出对话框 全选并改变TR颜色 选择文字就能选择复选框 简洁的TAB 阿里妈妈的商城分类效果一
用 JavaScript 实现网页图片等比例缩放
Lee Vane · 2008-10-09 · via 博客园 - Lee Vane

在处理网页图片时,特别是一些图片列表的应用里面,很难保证图片统一大小,直接设置图片大小又会导致图片拉伸,造成图片模糊,本文介绍的代码可以在图片加载完成后自动按比例调整图片大小。

Javascript:

  1. <script language="JavaScript" type="text/javascript">

  2. <!--

  3. function DrawImage(ImgD,FitWidth,FitHeight){

  4. var image=new Image();

  5. image.src=ImgD.src;

  6. if(image.width>0 && image.height>0){

  7. if(image.width/image.height>= FitWidth/FitHeight){

  8. if(image.width>FitWidth){

  9. ImgD.width=FitWidth;

  10. ImgD.height=(image.height*FitWidth)/image.width;

  11. }else{

  12. ImgD.width=image.width;

  13. ImgD.height=image.height;

  14. }

  15. } else{

  16. if(image.height>FitHeight){

  17. ImgD.height=FitHeight;

  18. ImgD.width=(image.width*FitHeight)/image.height;

  19. }else{

  20. ImgD.width=image.width;

  21. ImgD.height=image.height;

  22. }

  23. }

  24. }

  25. }

  26. //-->

  27. </script>

调用方式:
Code:

<img src="1148202890.jpg" alt="自动缩放后的效果" onload="javascript:DrawImage(this,200,200);" />

如果图片较大,建议在图片标签里面同时设置期望的图片大小,这样不会导致页面在加载中撑开,该大小不会影响最终缩放效果。可以修改上面的代码为:

Code:

<img src="1148202890.jpg" alt="自动缩放后的效果" width="200" height="200" onload="javascript:DrawImage(this,200,200);" />