css background-origin属性怎么用
程序员文章站
2022-03-09 11:33:00
...
css background-origin属性background-origin属性用于设置背景图片的定位区域。语法:background-origin: padding-box|border-box|content-box;其中三个属性值分别表示:相对于内边距框定位、相对于边框盒定位、相对于内容框定位。
css background-origin属性怎么用?
作用:规定 background-position 属性相对于什么位置来定位。
语法:
background-origin: padding-box|border-box|content-box;
说明:padding-box 背景图像相对于内边距框来定位。border-box 背景图像相对于边框盒来定位。content-box 背景图像相对于内容框来定位。
注释:如果背景图像的 background-attachment 属性为 "fixed",则该属性没有效果。
css background-origin属性使用示例
<!DOCTYPE html> <html> <head> <style> div { border:1px solid black; padding:35px; background-image:url('https://img.php.cn/upload/article/000/005/656/5af270fd37755429.jpg'); background-repeat:no-repeat; background-position:left; } #div1 { background-origin:border-box; } #div2 { background-origin:content-box; } </style> </head> <body> <p>background-origin:border-box:</p> <div id="div1"> 这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。 </div> <p>background-origin:content-box:</p> <div id="div2"> 这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。 </div> </body> </html>
效果输出:
以上就是css background-origin属性怎么用的详细内容,更多请关注其它相关文章!
上一篇: 关于继承和多态性的实例代码
下一篇: 怎么用PHPmyadmin创建数据库
推荐阅读
-
在css3中background-clip属性与background-origin属性的用法介绍
-
ACDsee怎么用?acdsee做图像属性的教程
-
VS2019怎么设置CSS的默认属性?
-
2个属性用CSS实现图片自适应浏览器
-
怎么用css属性屏蔽鼠标事件(鼠标点击可穿透上层元素)
-
css中background-origin属性的使用
-
关于用图片做无序列表的项目符号,我做出来怎么是这个样子?_html/css_WEB-ITnose
-
怎么用dreamweaver做一个可以换肤的界面_html/css_WEB-ITnose
-
发现一个特效会让你有意思,有人知道这个用css可以做出来吗,怎么做?_html/css_WEB-ITnose
-
symfony怎么用css来控制表单的样式?