2023CSS 内容框值

 所属分类:web前端开发

 浏览:32次-  评论: 0次-  更新时间:2023-09-06
描述:更多教程资料进入php教程获得。 使用 CSSbackground-origin 属性设置内容框值。通过 content-box 值,背景图像从内容的左上角...
更多教程资料进入php教程获得。

CSS 内容框值

使用 CSSbackground-origin 属性设置内容框值。通过 content-box 值,背景图像从内容的左上角开始。

示例

现场演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         #value1 {
            border: 3px solid blue;
            padding: 30px;
            background: url(https://img.zzsucai.com/202309/06/HbuyV31673014207.jpg);
            background-repeat: no-repeat;
            background-origin: padding-box;
         }

         #value2 {
            border: 3px solid orange;
            padding: 30px;
            background: url(https://img.zzsucai.com/202309/06/HbuyV31673014207.jpg);
            background-repeat: no-repeat;
            background-origin: border-box;
         }

         #value3 {
            border: 3px dashed yellow;
            padding: 30px;
            background: url(https://img.zzsucai.com/202309/06/HbuyV31673014207.jpg);
            background-repeat: no-repeat;
            background-origin: content-box;
         }
      </style>
   </head>

   <body>
      <h1>padding-box value</h1>
      <div id = "value1">
         <h2>Heading 2</h2>
         <p>This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
         <h3>Heading 3</h3>
         This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.</p>
      </div>

      <h1>border-box value</h1>
      <div id = "value2">
         <h2>Heading 2</h2>
         <p>This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
         <h3>Heading 3</h3>
         This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.</p>
      </div>

      <h1>content-box value</h1>
      <div id = "value3">
         <h2>Heading 2</h2>
         <p>This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
         <h3>Heading 3</h3>
         This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.</p>
      </div>
   </body>
</html>

 标签:
积分说明:注册即送10金币,每日签到可获得更多金币,成为VIP会员可免金币下载! 充值积分充值会员更多说明»

讨论这个素材(0)回答他人问题或分享使用心得奖励金币

〒_〒 居然一个评论都没有……

表情  文明上网,理性发言!