Home > Web Front-end > Front-end Q&A > How to set image stretching without repetition in css

How to set image stretching without repetition in css

藏色散人
Release: 2021-06-08 11:24:48
Original
2481 people have browsed it

Css method to set image stretching without duplication: first set the image path through "background: url("../../../static/imagic/sy.jpg")"; then through " "no-repeat" attribute can be used to set the image not to be repeated.

How to set image stretching without repetition in css

The operating environment of this article: windows7 system, HTML5&&CSS3 version, DELL G3 computer

css setting background image Stretch the full screen without duplication

Without further ado, let’s just go ahead and show the picture. We only gave the width and height 100% and this situation will occur

How to set image stretching without repetition in css

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

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

background: url("../../../static/imagic/sy.jpg") ——The location of the image path;

no-repeat—— The pictures are not repeated;

center 0px - center is the positioning from the left side of the page, 0px is the positioning from the top of the page;

background-position: center 0 - is the positioning of the picture, the same as above ;

background-size: cover;——Expand the background image to a large enough size so that the background image completely covers the background area. Some parts of the background image may not be displayed in the background positioning area;

min-height: 100vh; - the height of the window, "view area" refers to the size of the visible area inside the browser, that is window.innerWidth/ window.innerHeight size.

Recommended learning: "css video tutorial"

The above is the detailed content of How to set image stretching without repetition in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template