diff --git a/src/base/single/backgroundimage/background.image.js b/src/base/single/backgroundimage/background.image.js new file mode 100644 index 000000000..b7e70edde --- /dev/null +++ b/src/base/single/backgroundimage/background.image.js @@ -0,0 +1,30 @@ +/** + * 用于设置背景图的区域 + * @class BI.BackgroundImage + * @extends BI.Single + */ +BI.BackgroundImage = BI.inherit(BI.Single, { + props: { + baseCls: "bi-background-image", + url: "", + width: "100%", + height: "100%" + }, + + render: function () { + this.setUrl(this.options.url); + }, + + setUrl: function (url) { + this.options.url = url; + this.element.css({ + "background-image": "url(" + url + ")" + }); + }, + + getUrl: function () { + return this.options.url; + } +}); + +BI.shortcut("bi.background_image", BI.BackgroundImage); diff --git a/src/less/base/single/backgroundimage/background.image.less b/src/less/base/single/backgroundimage/background.image.less new file mode 100644 index 000000000..40878c607 --- /dev/null +++ b/src/less/base/single/backgroundimage/background.image.less @@ -0,0 +1,5 @@ +.bi-background-image { + background-size: cover; + background-position: center center; + background-repeat: no-repeat; +} \ No newline at end of file