小兔网

css设置图片拉伸不重复的方法:首先通过“background: url("../../../static/imagic/sy.jpg")”设置图片路径;然后通过“no-repeat”属性设置图片不重复即可。

css怎么设置图片拉伸不重复-前端问答

本文操作环境:windows7系统、HTML5&&CSS3版,DELL G3电脑

css设置背景图片拉伸全屏不重复

话不多说直接上图我们只给了宽和高100%就会出现这种状况

css怎么设置图片拉伸不重复-前端问答

<template>  <div class="hello"></div></template> <script>export default {  name: "HelloWorld",  data() {    return {};  }};</script>

<style scoped>.hello {  background: url("../../../static/imagic/sy.jpg") no-repeat;  height: 100%;  width: 100%;  background-size: cover;//全屏展示}</style>

background: url("../../../static/imagic/sy.jpg") ——图片路径的位置;

no-repeat—— 图片不重复;

center 0px——center是距离页面左边的定位,0px是距离页面上面的定位;

background-position: center 0——就是图片的定位,同上;

background-size: cover;——把背景图像扩展至足够大,以使背景图像完全覆盖背景区域。背景图像的某些部分也许无法显示在背景定位区域中;

min-height: 100vh;——视窗的高度,“视区”所指为浏览器内部的可视区域大小,即window.innerWidth/ window.innerHeight大小。

推荐学习:《css视频教程

以上就是css怎么设置图片拉伸不重复的知识。速戳>>知识兔学习精品课!