2.1背景位置——精确单位

提示:背景位置精确单位。

1、语法:

              div{

                   background-image:url(图片位置);

                   background-position:20px  50px;

                  }

background-image:url()

两个属性值: none

                       url

background-position:20px   50px;

第一个值表示x轴为20像素

第二个值表示y轴为50像素

background-position:20px;

只写一个值,则另一个一定默认为居中

自己代码展示:

<!--
 * @Author: error: git config user.name && git config user.email & please set dead value or install git
 * @Date: 2022-06-06 14:50:43
 * @LastEditors: error: git config user.name && git config user.email & please set dead value or install git
 * @LastEditTime: 2022-09-04 13:29:08
 * @FilePath: \code\前端代码\css学习知识\css背景\2.1背景位置——精确单位.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE 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>

显示结果:


 

总结

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值