CSS3 - 多个背景(Background(

CSS3 - 多个背景(Background( 首页 / CSS入门教程 / CSS3 - 多个背景(Background(

CSS Multi background属性用于一次添加一个或多个图像而无需改动HTML代码,无涯教程可以根据需要添加图像。多背景图像的示例语法如下-

#multibackground {
   background-image: url(/css/images/logo.png), url(/css/images/border.png);
   background-position: left top, left top;
   background-repeat: no-repeat, repeat;
   padding: 75px;
}

最常用的值如下所示-

Sr.No.Value & Remark
1

background

用于在一个区域中设置所有背景图像属性

2

background-clip

用于声明背景的绘画区域

3

background-image

链接:https://www.learnfk.comhttps://www.learnfk.com/css/css3-multi-background.html

来源:LearnFk无涯教程网

用于指定背景图片

4

background-origin

用于指定背景图像的位置

5

background-size

用于指定背景图像的大小

以下是演示多背景图像的示例。

<html>
   <head>
      <style>
         #multibackground {
            background-image: url(/css/images/logo.png), url(/css/images/border.png);
            background-position: left top, left top;
            background-repeat: no-repeat, repeat;
            padding: 75px;
         }
      </style>
   </head>

   <body>
   
      <div id="multibackground">
         <h1>www.learnfk.com</h1>
         <p>
            Learnfk Point originated from the idea that there exists a class of 
            readers who respond better to online content and prefer to learn new 
            skills at their own pace from the comforts of their drawing rooms. 
            The journey commenced with a single tutorial on HTML in  2006 and elated 
            by the response it generated, we worked our way to adding fresh Learnfk 
            to our repository which now proudly flaunts a wealth of Learnfk and 
            allied articles on topics ranging from programming languages to web designing 
            to academics and much more..
         </p>
      </div>
      
   </body>
</html> 

它将产生以下输出-

Multi background 图像大小 

接受多背景属性可为不同的图像添加不同的大小。示例语法如下所示-

#multibackground {
   background: url(/css/imalges/logo.png) left top no-repeat, url(/css/images/boarder.png) right bottom no-repeat, url(/css/images/css.gif) left top repeat;
   background-size: 50px, 130px, auto;
}

如上例所示,每个图像的具体尺寸分别为50px,130px和自动尺寸。

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

人工智能基础课 -〔王天一〕

Service Mesh实践指南 -〔周晶〕

从0开始学架构 -〔李运华〕

从0开始学游戏开发 -〔蔡能〕

React Hooks 核心原理与实战 -〔王沛〕

人人都用得上的数字化思维课 -〔付晓岩〕

JavaScript进阶实战课 -〔石川〕

快速上手C++数据结构与算法 -〔王健伟〕

手把手带你写一个MiniSpring -〔郭屹〕

好记忆不如烂笔头。留下您的足迹吧 :)