{"id":2350,"date":"2023-11-14T15:10:41","date_gmt":"2023-11-14T03:59:47","guid":{"rendered":""},"modified":"2023-11-14T11:59:47","modified_gmt":"2023-11-14T03:59:47","slug":"CSS background-attachment","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/2350.html","title":{"rendered":"CSS background-attachment"},"content":{"rendered":"


\n <\/head>
\n <\/p>\n

\n

CSS background-attachment<\/h1>\n<\/p><\/div>\n
\n CSS background-attachment\u7528\u4e8e\u6307\u5b9a\u80cc\u666f\u56fe\u50cf\u662f\u56fa\u5b9a\u7684\u8fd8\u662f\u5728\u6d4f\u89c8\u5668\u7a97\u53e3\u4e2d\u4e0e\u9875\u9762\u7684\u5176\u4f59\u90e8\u5206\u4e00\u8d77\u6eda\u52a8\u3002\n <\/div>\n
\n \u6b64\u5c5e\u6027\u5177\u6709\u4e09\u4e2a\u503c\uff1a
\n scroll\u3001fixed\u3001local<\/strong>\u3002\u5176\u9ed8\u8ba4\u503c\u4e3a
\n scroll <\/strong>\uff0c\u8fd9\u5c06\u5bfc\u81f4\u5143\u7d20\u4e0d\u968f\u5185\u5bb9\u6eda\u52a8\u3002\u6b64\u5c5e\u6027\u7684
\n local <\/strong>\u503c\u4f7f\u5143\u7d20\u968f\u5185\u5bb9\u6eda\u52a8\u3002\u5982\u679c\u5c06\u503c\u8bbe\u7f6e\u4e3a
\n fixed<\/strong>\uff0c\u5219\u5728\u6d4f\u89c8\u5668\u4e2d\u6eda\u52a8\u65f6\u80cc\u666f\u56fe\u50cf\u5c06\u4e0d\u4f1a\u79fb\u52a8\n <\/div>\n
\n \u6b64
\n CSS\u5c5e\u6027\u53ef\u4ee5\u652f\u6301\u591a\u4e2a\u80cc\u666f\u56fe\u50cf\u3002\u6211\u4eec\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u80cc\u666f\u56fe\u50cf\u6307\u5b9a\u4e0d\u540c\u7684
\n background-attachment <\/strong>\u5c5e\u6027\u503c\uff0c\u4ee5\u9017\u53f7\u5206\u9694\u3002\u6bcf\u4e2a\u56fe\u50cf\u90fd\u5c06\u4e0e\u6b64\u5c5e\u6027\u7684\u76f8\u5e94\u503c\u5339\u914d\u3002\n <\/div>\n

\u8bed\u6cd5<\/h3>\n
\n
 background-attachment: scroll | fixed | local | initial | inherit;
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6b64\u5c5e\u6027\u7684\u503c\u5b9a\u4e49\u5982\u4e0b\u3002\n <\/div>\n

\u5c5e\u6027\u503c<\/h3>\n
\n scroll\uff1a<\/strong>\u8fd9\u662f\u9ed8\u8ba4\u503c\u3002\n <\/div>\n
\n fixed\uff1a<\/strong>\u80cc\u666f\u56fe\u50cf\u4e0d\u4f1a\u968f\u5143\u7d20\u4e00\u8d77\u79fb\u52a8\uff0c\u5373\u4f7f\u5143\u7d20\u5177\u6709\u6eda\u52a8\u673a\u5236\u3002\n <\/div>\n
\n local\uff1a<\/strong>\u5982\u679c\u5143\u7d20\u5177\u6709\u6eda\u52a8\u673a\u5236\uff0c\u5219\u80cc\u666f\u56fe\u50cf\u5c06\u88ab\u9501\u5b9a\u5728\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u751a\u81f3\u6587\u6863\u7684\u5176\u4f59\u90e8\u5206\u4e5f\u5c06\u6eda\u52a8\u3002\u6eda\u52a8\u5143\u7d20\u7684\u5185\u5bb9\u3002\n <\/div>\n
\n initial\uff1a<\/strong>\u5c06\u5c5e\u6027\u8bbe\u7f6e\u4e3a\u5176\u9ed8\u8ba4\u503c\u3002\n <\/div>\n
\n inherit\uff1a<\/strong> \u5b83\u4ece\u5176\u7236\u5143\u7d20\u7ee7\u627f\u5c5e\u6027\u3002\n <\/div>\n
\n \u4e0b\u9762\u6211\u4eec\u901a\u8fc7\u4e00\u4e9b\u793a\u4f8b\u6765\u4e86\u89e3\u8fd9\u4e9b\u5c5e\u6027\u3002\n <\/div>\n

\u793a\u4f8b<\/h3>\n
\n \u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u662f\u4f7f\u7528
\n background-attachment <\/strong>\u5c5e\u6027\u7684
\n scroll <\/strong>\u503c\uff0c\u8fd9\u662f\u9ed8\u8ba4\u884c\u4e3a\u3002\u56e0\u6b64\uff0c\u5728\u6eda\u52a8\u9875\u9762\u65f6\uff0c\u80cc\u666f\u4e5f\u4f1a\u968f\u4e4b\u6eda\u52a8\u3002\n <\/div>\n
\n
 <!DOCTYPE html>
<html>
<head>
<title>
background-attachment property
<\/title>
<style>
#example {
background-image: url(\"lion.png\");
font-size: 35px;
border: 4px solid red;
color: white;
background-position: center;
background-color: green;
background-repeat: no-repeat;
background-attachment: scroll;
}
<\/style>
<\/head>
<body>
<h1> background-attachment: scroll;<\/h1>
<p> \u5982\u679c\u5c4f\u5e55\u4e0a\u6ca1\u6709\u6eda\u52a8\u6761\uff0c\u8bf7\u5c1d\u8bd5\u8c03\u6574\u6d4f\u89c8\u5668\u7a97\u53e3\u7684\u5927\u5c0f\u4ee5\u67e5\u770b\u6548\u679c\u3002 <\/p>
<div id=\"example\">
<p>
\u6b22\u8fce\u6765\u5230bianchenghao6.com\u5e73\u53f0\u3002\u7acb\u5730\u8d27\u7684\u76ee\u7684\u662f\u4f7f\u5927\u5bb6\u53ef\u4ee5\u8f7b\u677e\u5b66\u4e60\u5404\u79cd\u77e5\u8bc6\uff0c\u63d0\u4f9b\u5404\u79cd\u7b80\u5355\u4e14\u6df1\u5165\u7684\u6559\u7a0b\u3002\u5728\u8fd9\u4e2a\u4e16\u754c\u4e0a\u6ca1\u6709\u4eba\u662f\u5b8c\u7f8e\u7684\uff0c\u6ca1\u6709\u4ec0\u4e48\u662f\u6c38\u6052\u7684\uff0c\u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u5c1d\u8bd5\u53d8\u5f97\u66f4\u597d\u3002
<\/p>
<\/div>
<\/body>
<\/html>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa<\/strong>\n <\/div>\n

CSS background-attachment_https:\/\/bianchenghao6.com_\u3010CSS \u6559\u7a0b\u3011_\u7b2c1\u5f20 <\/p>\n

\u793a\u4f8b-\u4f7f\u7528\u56fa\u5b9a\u503c<\/h3>\n
\n \u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528
\n background-attachment <\/strong>\u5c5e\u6027\u7684
\n fixed <\/strong>\u503c\u3002\u6b64\u503c\u56fa\u5b9a\u4e86\u80cc\u666f\u56fe\u50cf\uff0c\u5373\u4f7f\u5176\u4f59\u6587\u6863\u6eda\u52a8\uff0c\u8be5\u56fe\u50cf\u4e5f\u4e0d\u4f1a\u79fb\u52a8\u3002\n <\/div>\n
\n
 <!DOCTYPE html>
<html>
<head>
<title>
background-attachment property
<\/title>
<style>
#example {
background-image: url(\"lion.png\");
font-size: 35px;
border: 4px solid red;
color: white;
background-position: center;
background-color: green;
background-repeat: no-repeat;
background-attachment: fixed;
}
<\/style>
<\/head>
<body>
<h1> background-attachment: fixed;<\/h1>
<p> \u5982\u679c\u5c4f\u5e55\u4e0a\u6ca1\u6709\u6eda\u52a8\u6761\uff0c\u8bf7\u5c1d\u8bd5\u8c03\u6574\u6d4f\u89c8\u5668\u7a97\u53e3\u7684\u5927\u5c0f\u4ee5\u67e5\u770b\u6548\u679c\u3002<\/p>
<div id=\"example\">
<p>
\u6b22\u8fce\u6765\u5230bianchenghao6.com\u5e73\u53f0\uff0c\u7acb\u5730\u8d27\u7684\u76ee\u7684\u662f\u4f7f\u5927\u5bb6\u53ef\u4ee5\u8f7b\u677e\u5b66\u4e60\u5404\u79cd\u77e5\u8bc6\uff0c\u63d0\u4f9b\u5404\u79cd\u7b80\u5355\u4e14\u6df1\u5165\u7684\u6559\u7a0b\u3002\u5728\u8fd9\u4e2a\u4e16\u754c\u4e0a\u6ca1\u6709\u4eba\u662f\u5b8c\u7f8e\u7684\uff0c\u6ca1\u6709\u4ec0\u4e48\u662f\u6c38\u6052\u7684\uff0c\u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u5c1d\u8bd5\u53d8\u5f97\u66f4\u597d\u3002
<\/p>
<\/div>
<\/body>
<\/html>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa<\/strong>\n <\/div>\n

CSS background-attachment_https:\/\/bianchenghao6.com_\u3010CSS \u6559\u7a0b\u3011_\u7b2c2\u5f20 <\/p>\n

\u793a\u4f8b-\u4f7f\u7528\u5c40\u90e8\u503c<\/h3>\n
\n \u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528
\n background-attachment <\/strong>\u5c5e\u6027\u7684
\n local <\/strong>\u503c\u3002\u5728\u8fd9\u91cc\uff0c\u80cc\u666f\u56fe\u50cf\u5c06\u968f\u7740\u5143\u7d20\u5185\u5bb9\u7684\u6eda\u52a8\u800c\u6eda\u52a8\u3002\n <\/div>\n
\n
 <!DOCTYPE html>
<html>
<head>
<title>
background-attachment property
<\/title>
<style>
#example {
background-image: url(\"lion.png\");
font-size: 35px;
border: 4px solid red;
color: white;
background-position: center;
background-color: green;
background-repeat: no-repeat;
background-attachment: local;
}
<\/style>
<\/head>
<body>
<h1> background-attachment: local;<\/h1>
<p>\u5982\u679c\u5c4f\u5e55\u4e0a\u6ca1\u6709\u6eda\u52a8\u6761\uff0c\u8bf7\u5c1d\u8bd5\u8c03\u6574\u6d4f\u89c8\u5668\u7a97\u53e3\u7684\u5927\u5c0f\u4ee5\u67e5\u770b\u6548\u679c\u3002<\/p>
<div id=\"example\">
<p>
\u6b22\u8fce\u6765\u5230bianchenghao6.com\u5e73\u53f0\uff0c\u7acb\u5730\u8d27\u7684\u76ee\u7684\u662f\u4f7f\u5927\u5bb6\u53ef\u4ee5\u8f7b\u677e\u5b66\u4e60\u5404\u79cd\u77e5\u8bc6\uff0c\u63d0\u4f9b\u5404\u79cd\u7b80\u5355\u4e14\u6df1\u5165\u7684\u6559\u7a0b\u3002\u5728\u8fd9\u4e2a\u4e16\u754c\u4e0a\u6ca1\u6709\u4eba\u662f\u5b8c\u7f8e\u7684\uff0c\u6ca1\u6709\u4ec0\u4e48\u662f\u6c38\u6052\u7684\uff0c\u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u5c1d\u8bd5\u53d8\u5f97\u66f4\u597d\u3002
<\/p>
<\/div>
<\/body>
<\/html>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa<\/strong>\n <\/div>\n

CSS background-attachment_https:\/\/bianchenghao6.com_\u3010CSS \u6559\u7a0b\u3011_\u7b2c3\u5f20 <\/p>\n

\n \u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u6765\u770b\u53e6\u4e00\u4e2a\u793a\u4f8b\uff0c\u5176\u4e2d\u4e00\u4e2a\u5143\u7d20\u4f7f\u7528\u4e86\u591a\u4e2a\u80cc\u666f\u56fe\u50cf\u3002\n <\/div>\n

\u793a\u4f8b<\/h3>\n
\n \u5728\u8fd9\u91cc\uff0c\u6709\u4e24\u4e2a\u80cc\u666f\u56fe\u50cf\u6211\u4eec\u6b63\u5728\u5e94\u7528
\n background-attachment <\/strong>\u5c5e\u6027\u3002\u7b2c\u4e00\u5f20\u56fe\u7247\u7684\u9644\u4ef6\u8bbe\u7f6e\u4e3a
\n \u56fa\u5b9a<\/strong>\uff0c\u800c\u7b2c\u4e8c\u5f20\u56fe\u7247\u7684\u9644\u4ef6\u8bbe\u7f6e\u4e3a
\n \u6eda\u52a8<\/strong>\u3002\n <\/div>\n
\n
 <!DOCTYPE html>
<html>
<head>
<title>
background-attachment property
<\/title>
<style>
#example {
background-image:url(\"https:\/\/bianchenghao6.com\/images\/logo.png\");
height: 500px;
border: 4px solid red;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed, scroll;
}
<\/style>
<\/head>
<body>
<h1> background-attachment: scroll;<\/h1>
<p>\u5982\u679c\u5c4f\u5e55\u4e0a\u6ca1\u6709\u6eda\u52a8\u6761\uff0c\u8bf7\u5c1d\u8bd5\u8c03\u6574\u6d4f\u89c8\u5668\u7a97\u53e3\u7684\u5927\u5c0f\u4ee5\u67e5\u770b\u6548\u679c\u3002<\/p>
<div id=\"example\">
<\/div>
<\/body>
<\/html>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa<\/strong>\n <\/div>\n

CSS background-attachment_https:\/\/bianchenghao6.com_\u3010CSS \u6559\u7a0b\u3011_\u7b2c4\u5f20
\n <\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"zh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[175],"tags":[],"class_list":["post-2350","post","type-post","status-publish","format-standard","hentry","category-css-jc"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/2350"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=2350"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/2350\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=2350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=2350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=2350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}