Self-understanding of the background-position attribute in background image positioning

Self-understanding of the background-position attribute in background image positioning

Recently, I need to use a lot of fragmented pictures such as labels and buttons in the project. In addition, I have never had the opportunity to use the "elf technology" in CSS. Here I write my understanding of background-position into a document for more people to use and learn.

The combination of all existing button images

Step 1 : We want to display This button, then we must first define a div (later called the window) tag, the width and height of which should just be able to hold this button.

Step 2 : This is the focus of my talk today. Many people say that background-position is the background image of the operation, but I say it is the window of the operation. Through the window we can only see a part of the background image .

The understanding of the horizontal and vertical coordinates is that as long as the window moves within the area of ​​the image, we say it is in the negative direction (negative coordinates).

show For this image button, we don't need to specify the coordinates, it is the default. Of course you can also #div5{background-position: 0px 0px;}

show For this image button, you must set the background-position coordinates, #div6{ background-position:-42px 0px;}

show This image button, #div8{ background-position:-42px -41px;}

The same applies to the following.

Many of you may understand what I am saying here. I am just telling you a way of understanding for those who are just getting started. If there is anything wrong, please criticize me. (I don’t know how to typeset, hope you understand)

<<:  This article will show you the principle of MySQL master-slave synchronization

>>:  CSS specification BEM CSS and OOCSS sample code detailed explanation

Recommend

CentOS7 uses rpm to install MySQL 5.7 tutorial diagram

1. Download 4 rpm packages mysql-community-client...

Binary Type Operations in MySQL

This article mainly introduces the binary type op...

How to collect Nginx logs using Filebeat

Nginx logs can be used to analyze user address lo...

Detailed explanation of CSS multiple three-column adaptive layout implementation

Preface In order to follow the conventional WEB l...

Correct use of Vue function anti-shake and throttling

Preface 1. Debounce: After a high-frequency event...

Syntax alias problem based on delete in mysql

Table of contents MySQL delete syntax alias probl...

Sample code for implementing a background gradient button using div+css3

As the demand for front-end pages continues to in...

Detailed discussion on the issue of mysqldump data export

1. An error (1064) is reported when using mysqldu...

Detailed tutorial on installing and using Kong API Gateway with Docker

1 Introduction Kong is not a simple product. The ...

How to install grafana and add influxdb monitoring under Linux

Install grafana. The official website provides an...

Mysql 5.6.37 winx64 installation dual version mysql notes

If MySQL version 5.0 already exists on the machin...

Complete example of vue polling request solution

Understanding of polling In fact, the focus of po...