300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > html怎么设置拉伸图片大小 html – 如何在不拉伸的情况下调整图像大小?

html怎么设置拉伸图片大小 html – 如何在不拉伸的情况下调整图像大小?

时间:2019-01-24 01:24:05

相关推荐

html怎么设置拉伸图片大小 html – 如何在不拉伸的情况下调整图像大小?

诀窍是将图像放入包含块元素,例如DIV.一旦将图像的宽度设置为100%,这将指示浏览器使图像宽度与DIV的左右边缘齐平.

然后,您通过CSS控制DIV的宽度,我发现将图像保留在块元素中可以在创建流体布局时更轻松地进行操作.

例:

img.stretchy {

width: 100%; /*Tells image to fit to width of parent container*/

}

.container {

width: 33%; /*Use this to control width of the parent container,hence the image*/

}

如果要以任何方式剪切/裁剪图像,请将其设置为大于其父级,并将父级的溢出css设置为隐藏.

例:

img.clipped {

width: 150%; /*Scales image to 150% width of parent container*/

float: left; /*Floats image to left of container - clipping right hand side*/

float: right; /*Floats image to right of container - clipping left hand side*/

}

.container {

width: 33%; /*Use this to control width of the parent container,hence the image*/

overflow: hidden;

}

希望这可以帮助…

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。