Various categories of SVG failing to display

I am attempting to utilize an svg for a new website background pattern that I'm developing. I came across one that I like and I am trying to customize it for my use.

The SVG I downloaded looks like this:

<svg xmlns="http://www.w3.org/2000/svg" width="100" height="199" viewBox="0 0 100 199"><g fill="#000"><path d="M0 199V0h1v1.99L100 199h-1.12L1 4.22V199H0zM100 2h-.12l-1-2H100v2z"></path></g></svg>

When I set the background image like this:

.my-div {
   background-image: url("mysvg-black.svg")
}

It works perfectly, but it's in black color. To change the color, I opened Photoshop, customized the SVG, and exported it. The updated SVG now looks like this:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="417" height="829" viewBox="0 0 417 829">
  <image width="417" height="829" xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaEAAAM9CAYAAAA1k8zTAAATG0lEQVR4nO3dzZEjSXaFUTSN4oxQQ1EoCSlUCzCaDI3VVdVZWQkgftz9Pnc/Z4kNAsDiswsgI...

However, when I try setting the background image to the red SVG like this:

.my-div {
   background-image: url("mysvg-red.svg")
}

Nothing seems to show up on the background. It appears that the SVG exported from Photoshop contains more tags than the originally downloaded one.

If anyone can assist me with this issue, I would greatly appreciate it!

Thank you!

Answer №1

Actually, the SVG code provided is quite simple. To change only the color, you just need to modify the fill attribute value within the g tag. Here's an example:

<svg xmlns="http://www.w3.org/2000/svg" width="100" height="199" viewBox="0 0 100 199">
    <g fill="#f00">
        <path d="M0 199V0h1v1.99L100 199h-1.12L1 4.22V199H0zM100 2h-.12l-1-2H100v2z"></path>
    </g>
</svg>

If you want to adjust the size, you can use background-size. The SVG created earlier was large in size.

For more intricate modifications, specialized software for manipulating SVG files may be necessary.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Prevent HTML from being escaped in data-binding while utilizing repeat-templates in Polymer

Hey there! <template repeat="{{item in items}}"> <div layout horizontal> <div>{{item['content']}}</div> <div>{{item['more_content'])}</div> ...

CSS dropdown fix for improved responsiveness

Check out this Fiddle >> http://jsfiddle.net/fpCpc/`"> jsfiddle Having a problem where the top part of the dropdown navigation doesn't stay active when scrolling down. I even captured a screenshot for clarification! Screenshot Any tips or ...

Obtain the href using a combination of xpath and id

I need to extract the href links for 9 search results from this specific website. The xpath and selectors for the first, second, and third items are as follows: '//*[@id="search-results"]/div[4]/div/ctl:cache/div[3]/div[1]/div/div[2]/div[2]/div[2]/p[ ...

Developing an object that displays animated effects when modifying its properties, such as visibility, and more

Exploring the realm of animations in JavaScript and AngularJS has led me to the idea of creating a unique JavaScript object. Imagine having the ability to define an object where setting an attribute like obj.visible = true Would automatically make the ...

Use one tag to abbreviate multiple times

As I create a step-by-step guide, I want the audience to be able to hover over any word in the text and see its definition. However, I only want to define abbreviations once. Is there a method in html or css that allows me to achieve this? ...

Enhancing user experience with Bootstrap's body padding and customizable scrollbars

Recently, I encountered an issue with the footer color in bootstrap. To fix this problem, I created a div and removed the extra padding from the body element. You can view the code snippet here: jsfiddle.net/wctGM/9/ However, when viewing the mobile ver ...

Tips for troubleshooting CSS to eliminate scrollbars?

My website shares similar css with I am facing an issue where vertical and horizontal scrollbars are appearing in unwanted positions. Using Firefox, I am trying to troubleshoot the problem using the inspector. https://i.sstatic.net/K3pGL.png What steps ...

Utilizing jQuery to dynamically load CSS files on a webpage

For my website, I have implemented 4 different .css files to handle various screen resolutions. Here is the innovative jquery code I've developed to dynamically load these files based on the width of the screen. <link id="size-stylesheet" rel="st ...

Experiencing a problem when attempting to activate the html5 mode feature in AngularJS to eliminate the #

I've been scouring through various sources like stackoverflow and the web, but I haven't found a clear answer to my question. Can someone please help me out? Here's what I'm struggling with: In my AngularJS application, I enabled &apos ...

Attempting to use PHP to send emails with an email address associated with Microsoft's SMTP servers, such as those ending in @live.com or @outlook.com

I have been attempting to utilize a PHP script to send an email. The specific line of code responsible for sending the email is as follows: mail($owner_email, $subject, $messageBody, $headers) Below are the values assigned to my variables: $owner_email ...

presentation not transitioning smoothly as the next slide appears

Initially, my aim is to center the slideshow on the page but I am uncertain about how to achieve it. This is how my current webpage appears: https://i.sstatic.net/E6bzQ.png Furthermore, as shown in the image, the sliding effect of the blue slide is movi ...

Pass the value of a button to jQuery AJAX using the onclick() function

Can a value be passed from a button to Jquery AJAX using the onclick function? I attempted to use this code, but it doesn't seem to be working. Nothing is showing up in the console log. HTML <button type="button" class="hapus_krs" onclick="hapus_ ...

HTML code displaying a fixed message at the top of the webpage

I'm working on a web page that has a lot of content. I need to have a message always visible at the bottom of the browser window, even when scrolling. Can anyone help me achieve this using simple CSS, HTML, jQuery, or PHP? Thanks! ...

Trouble with Chrome's CSS making table cell display as block

After searching, I stumbled upon this question that appeared to have the solution I needed. Surprisingly, even when using chrome 32.0.1700.102, the fiddle provided in the first answer worked perfectly for me. However, when I copied the HTML code into a ne ...

Scrolling with animation

While exploring the Snapwiz website, I came across a captivating scroll effect that I would love to implement on my own site. The background picture changes seamlessly as you scroll, with the front image sliding elegantly into view. A similar type of scro ...

What is the best way to create a modal message box using AngularJS?

Here is some code that I need help with: <body> <div> xxx </div> <div id="error" ng-show="er.msg"> <div style="color: white; background-color: purple; height: 2rem; display: flex; align-items: ...

The best way to centralize the input group in bootstrap

I attempted to center align my search bar, but it stubbornly stays to the left. Here's the code I'm using: <head> <style> html { overflow: auto; } html, body, iframe { ...

A guide on accessing the href attribute of an HTML tag using jQuery

My goal is to extract the ID from the href attribute of an a tag on my webpage. First, I need to prevent the page from refreshing before performing this task. The example a tags look like this: '<a href="/ArtPlaces/Delete/5">Delete</a>&ap ...

Can changes on a webpage in PHP be saved without needing to be sent to a database?

I've been conducting some research on this matter, but I haven't been able to find a solution. Is it feasible in PHP to save modifications made on a webpage without storing the information in a database? I want to empower users to edit their pag ...

Creating a stylish CSS effect by adding a dashed border underneath two div elements

Looking for help with a layout where there are two tables side by side, represented by the blue boxes. The goal is to be able to select a row in each table and then click the red link button below. The connecting lines between the boxes and the link button ...