{"id":51590,"date":"2015-08-10T02:06:05","date_gmt":"2015-08-10T06:06:05","guid":{"rendered":"http:\/\/www.templatemonster.com\/help\/?p=51590"},"modified":"2015-08-10T02:06:05","modified_gmt":"2015-08-10T06:06:05","slug":"js-animated-how-replace-color-background-with-image-in-css","status":"publish","type":"post","link":"https:\/\/www.templatemonster.com\/help\/js-animated-how-replace-color-background-with-image-in-css.html","title":{"rendered":"JS Animated. How replace color background with image in CSS"},"content":{"rendered":"<p>This tutorial shows how to replace <strong>background color <\/strong>with image in CSS.<\/p>\r\n<a href=\"http:\/\/www.youtube.com\/watch?v=wWRqaBt4eEM?width=1280&amp;height=720\" rel=\"prettyPhoto\">JS Animated. How replace color background with image in CSS<\/a>\r\n<ol>\r\n<li><p>Connect to server via <a target=\"_blank\" href=\"https:\/\/www.templatemonster.com\/help\/how-upload-files-server-2.html\">FTP<\/a> or open <a target=\"_blank\" href=\"https:\/\/www.templatemonster.com\/help\/how-to-upload-files-to-a-server-using-cpanel-webhost-manager-whm.html\">cPanel file manager<\/a>.\r\n  <\/p><\/li>\r\n<li>\r\n  <p>Open the <strong>images folder<\/strong> on server and upload image you would like to set as background into it.<\/p><\/li>\r\n\r\n  <li>\r\n    <p>When image is uploaded, copy correct path to the image. Usually it&#8217;s your <strong>site URL+images folder name+image name and format<\/strong>:<\/p>\r\n   \r\n<a href=\"\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-1.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-1-300x210.jpg\" alt=\"HTML.How replace color background with image in CSS-1\" width=\"300\" height=\"210\" class=\"aligncenter size-medium wp-image-51592\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-1-300x210.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-1-150x105.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-1.jpg 1000w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>\r\n<\/li>\r\n  <li>\r\n    <p>Next, open site in your browser and use the <a target=\"_blank\" href=\"https:\/\/www.templatemonster.com\/help\/developer-tools.html\">Inspect Element tool<\/a> to find what file and line you will need to edit:<\/p>\r\n    \r\n<a href=\"\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-2.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-2-300x210.jpg\" alt=\"HTML.How replace color background with image in CSS-2\" width=\"300\" height=\"210\" class=\"aligncenter size-medium wp-image-51593\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-2-300x210.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-2-150x105.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-2.jpg 1000w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>\r\n  <\/li>\r\n<li>\r\n    <p>Now replace the <strong>background<\/strong> property with the <strong>background-image<\/strong> one. In order to place image into the property, use the <strong>url(&#8220;&#8221;)<\/strong> value. Insert image path you&#8217;ve uploaded into quotation marks:<\/p>\r\n    <pre>background-image: url(&quot;http:\/\/demolink.org\/site\/images\/header-bg.jpg&quot;);<\/pre>\r\n  <\/li>\r\n<li>In case you&#8217;re uploading pattern image or image with smaller width, you can use the <strong>background-repeat<\/strong> property. It allows to repeat image vertically and horizontally, only vertically or horizontally or stop image repeating:<\/p>\r\n<pre>background-repeat: no-repeat;\r\nbackground-repeat: repeat-x;\r\nbackground-repeat: repeat-y;\r\nbackground-repeat: repeat;\r\n<\/pre>\r\n  <p>By default, background image is loaded in the top left corner of the element. You can move background image by using the <a target=\"_blank\" href=\"http:\/\/www.w3schools.com\/cssref\/pr_background-position.asp\">background-position property<a>. Final version of the line will look like the following:<\/p>\r\n<pre>.your element {\r\nbackground-image: url(&quot;http:\/\/demolink.org\/site\/images\/your_image.jpg&quot;);\r\nbackground-position: center center;\r\nbackground-repeat: no-repeat;}\r\n<\/pre>\r\n<\/li>\r\n  <li>\r\n    <p>Copy the edited line from <strong>Firebug\/Inspect Element<\/strong> with <strong>Ctrl\/Cmd+C hotkeys<\/strong>. There you can find path to CSS file that should be edited as well:<\/p>\r\n    \r\n<a href=\"\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-3.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-3-300x210.jpg\" alt=\"HTML.How replace color background with image in CSS-3\" width=\"300\" height=\"210\" class=\"aligncenter size-medium wp-image-51594\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-3-300x210.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-3-150x105.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2015\/08\/HTML.How-replace-color-background-with-image-in-CSS-3.jpg 1000w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>\r\n  <\/li>\r\n  <li>\r\n    <p>Find and edit CSS file required via FTP or cPanel file manager. You can edit file using online editor or any other HTML editor. Use <strong>Ctrl\/Cmd+F5 hotkeys<\/strong> to find code in case you editor is missing line numbers.<\/p>\r\n  <\/li>\r\n  <li><p>Find the line required and replace it with the updated code, i.e. with the one copied from Firebug\/Inspect Element.<\/p><\/li>\r\n  <li><p>Save changes in the file. Refresh page to check the changes. <\/p><\/li>\r\n  <\/ol>\r\n<p>Feel free to check the detailed video tutorial below:<\/p>\r\n\r\n<a href=\"http:\/\/www.youtube.com\/watch?v=wWRqaBt4eEM?width=1280&amp;height=720\" rel=\"prettyPhoto\">JS Animated. How replace color background with image in CSS<\/a>","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to replace <strong>background color <\/strong>with image in CSS.<\/p>\n","protected":false},"author":65,"featured_media":51813,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1016],"tags":[1008,520,514,537],"_links":{"self":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/51590"}],"collection":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/comments?post=51590"}],"version-history":[{"count":1,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/51590\/revisions"}],"predecessor-version":[{"id":83727,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/51590\/revisions\/83727"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media\/51813"}],"wp:attachment":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media?parent=51590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/categories?post=51590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/tags?post=51590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}