html - 使用 html(不是 css?)自动调整照片大小

标签 html image resize

我用于我的网站(基于 WordPress)的公司有一个“自动博客”,但有些帖子的图片对于屏幕来说太大了。我希望能够粘贴代码以确保长边仅为 500 像素,但保持比例正确。我是新手,所以请让我知道在页面上的哪个位置粘贴代码。提前致谢!!! http://embarkre.com/category/real-estate-news

示例代码:

<div>
<p class="subtitle">ESCAPE One is a road-ready tiny home with 276 square feet of adaptable space.</p>

<figure><img src="https://s3-us-west-2.amazonaws.com/dwell-ugc/photos/6063391372700811264/6301479718082105344/large.jpg" alt="" width="700" height="467" /></figure>
<div>

For those looking to downsize, Wisconsin-based builder of tiny homes-on-wheels <a href="http://www.escapetraveler.net/" target="_blank">ESCAPE</a> has launched its latest unit, the <a href="http://www.escapetraveler.net/model-one" target="_blank">ESCAPE One</a>. The 276-square-foot Park Model RV resembles a minimalist cottage with a shou-sugi-ban exterior and clean, pine interiors, and can sleep up to four people.

</div>
<figure><a href="https://www.dwell.com/article/hit-the-road-with-this-shou-sugi-ban-trailer-asking-just-under-dollar50k-d5961fd8/6301479715116331008"><img src="https://s3-us-west-2.amazonaws.com/dwell-ugc/photos/6063391372700811264/6301479715116331008/large.jpg" alt="" width="1600" height="1066" /></a>
<figcaption>ESCAPE RV/Steve Niedorf </figcaption></figure>
<div>

最佳答案

尝试在 HTML 的 HEAD 部分添加以下内容。

<style>
  img {
    max-width: 500px;
    height: auto;
  }
</style>

关于html - 使用 html(不是 css?)自动调整照片大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45622493/

相关文章:

html元素没有高度

image - 如何将图像添加到wordpress中的每个类别?

html - 如何更改输入文件按钮大小?

javascript - 通过拖动节点动态调整 DIV 大小

resize - 是否可以检查 PNG 图像是否具有透明背景?

javascript - 如何使用javascript动态生成id并将其赋予html SVG中的特定元素?

javascript - React 组件 - HTML 模板的存储位置

HTML/CSS : Horizontal bar/design on sites like jQuery

java - 使用大量数据的 Swing 应用程序

ruby-on-rails - 用于亚马逊 S3 的 AutoSmusher 优化图像?