提示:背景位置精确单位。
div{
background-image:url(图片位置);
background-position:20px 50px;
}
background-image:url()
两个属性值: none
url
background-position:20px 50px;
第一个值表示x轴为20像素
第二个值表示y轴为50像素
background-position:20px;
只写一个值,则另一个一定默认为居中
自己代码展示:
- html>
- <html lang="en">
-
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>精确单位title>
- <style>
- body {
- background-image: url(wzbj.jpg);
- /* 图片背景 */
- background-repeat: no-repeat;
- /* 平铺背景-属性值表示不要平铺 */
- background-position: 20px 50px;
- /* 这个表示图片精确位置;两个值是表示精确、x轴20px、y轴50px */
- /* 这个50像素(px)表示上向下顶 */
- }
- style>
- head>
-
- <body>
-
-
- body>
-
- html>
显示结果:

提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了背景位置精确单位。