rog*_*nin 3 html css wordpress image image-size
无论我在做什么,我都有 css 拉伸图像,但我看不到图像有多小,但它使它成为我正在使用的巨大高度
<?PHP the_post_thumbnail( 'full' ); ?>
Run Code Online (Sandbox Code Playgroud)
使用的 css 如下但你会看到它的原因
我的图像拉伸并且尺寸不正确。
.services-icon img {
max-width: 100%;
display: block;
width: 200px;
margin-top: 0;
margin-right: auto;
margin-bottom: 0;
margin-left: auto;
Run Code Online (Sandbox Code Playgroud)
网址在这里
您的<img>标签具有由 Wordpress 设置的awidth和 aheight属性。
<img width="1000" height="500" ... >
Run Code Online (Sandbox Code Playgroud)
在您的 CSS 中,您可以根据您的200px宽度设置自动高度以保持纵横比:
.services-icon img {
height: auto;
}
Run Code Online (Sandbox Code Playgroud)
请记住,您的 CSS 会覆盖此图像的 Wordpress 设置。