In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces css how to center the background picture, the article introduces in great detail, has a certain reference value, interested friends must read it!
In css, you can use the "background-position" attribute to center the background image, which is used to set the starting position of the background image. When the value of the attribute is "center", the background image will be centered horizontally and vertically, and the syntax "element {background-position:center}".
The operating environment of this tutorial: windows10 system, CSS3&&HTML5 version, Dell G3 computer.
How does css center the background image
In css, the location of the background picture can be set through the background-position property. Here is an example of how to center the background image in css.
Examples are as follows:
1. Create a new html file, named test.html, to explain how to center the background image in css. Use the div tag to create a module for testing. Set the class property of the div tag to test, which is used to set the following styles.
Within the css tag, style the div through class, defining a gray border with a width of 300px, a height of 300px, and a border of 1px.
2. In the css tag, use the background attribute to set the background image of the div to 1.jpg, and use the background-position attribute to set the background image center display.
Open the test.html file in the browser to see the effect of the implementation.
Summary:
1. Create a module using the div tag, and set the class attribute of the div tag to test, which is used to set the following styles.
2. Within the css tag, set the style of div through class, and define its width as 300px, height as 300px, and the border as the gray border of 1px.
3. In the css tag, use the background attribute to set the background image of div to 1.jpg, and use the background-position attribute to set the background image to be centered (center) display.
The above is all the contents of the article "how to center the background image by css". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.