What is the best way to change the color behind the SVG to black?

I'm having some trouble creating a signup form with SVG logos. The colors seem to clash and no matter what I do, the color doesn't change from white.

My goal is to have the actual SVG logo remain white while the background behind it is black. Here's the code I've been working on:

https://pastebin.com/zzW4Y1m6 -- HTML

.form-control {
    width: 100%; /* Make sure the input fills the container */
    height: 48px;
    padding: 0px 8px;
    border: 1px solid transparent; /* Remove default border */
    box-sizing: border-box;
    border-radius: 12px;
    background-color: #141414; /* Darker color for input box */
    color: #bababa; /* Default text color */
    font-size: 14px;
    font-family: "Poppins";
    font-weight: 500;
    line-height: 18px;
    outline: none;
    transition: background-color 0.3s ease, color 0.3s ease; /* Smooth focus effect transition */
}

.logo-wrapper {
    position: relative;
    background-color: black; /* Set logo area background to black */
}

.logo-wrapper img {
    position: absolute;
    top: 50%; /* Vertically center */
    left: 50%; /* Horizontally center */
    transform: translate(-50%, -50%);
}

.form-control:focus {
    background-color: #141414; /* Keep original background color on focus */
    color: #ffffff; /* Change text color to white on focus */
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); /* Add light gray curved outline on focus */
}
<body>
    <div class="signup-container">
        <div class="signup-image">
            <img src="x.jpg" alt="Signup Image">
        </div>
        <div class="signup-form">
            <h2 class="signup-title">Sign Up</h2>
            <h4 class="signup-info">Join QuizGenius To Unlock Quizzes!</h4>
            <form>
                <div class="mb-3">
                    <label for="name" class="input-description">Your full name</label>
                    <div class="input-group">
                        <input type="text" class="form-control" id="name" placeholder="First Last">
                        <span class="input-group-text logo"><svg xmlns="http://www.w3.org/2000/svg" style="width: 24px; height: 24px; overflow: visible; fill: rgb(255, 255, 255);" viewBox="0 0 576 512"><path d="M528 32h-480C21.49 32 0 53.49 0 80V96h576V80C576 53.49 554.5 32 528 32zM0 432C0 458.5 21.49 480 48 480h480c26.51 0 48-21.49 48-48V128H0V432zM368 192h128C504.8 192 512 199.2 512 208S504.8 224 496 224h-128C359.2 224 352 216.8 352 208S359.2 192 368 192zM368 256h128C504.8 256 512 263.2 512 272S504.8 288 496 288h-128C359.2 288 352 280.8 352 272S359.2 256 368 256zM368 320h128c8.836 0 16 7.164 16 16S504.8 352 496 352h-128c-8.836 0-16-7.164-16-16S359.2 320 368 320zM176 192c35.35 0 64 28.66 64 64s-28.65 64-64 64s-64-28.66-64-64S140.7 192 176 192zM112 352h128c26.51 0 48 21.49 48 48c0 8.836-7.164 16-16 16h-192C71.16 416 64 408.8 64 400C64 373.5 85.49 352 112 352z"></path></svg></span>
                    </div>
                </div>
               <!-- More input fields go here -->
               <!-- Additional SVG logos can be added following the same structure -->
               
</body>

Answer №1

To display the svg in a "div" tag instead of a span, you can simply place the svg inside a "div" element and apply the following properties to the div:

.custom-logo{
    position: relative;
    width: max-content;
    background-color: black;
    height: 24px;
}

If you wish to change the color of the SVG, you can use the following styling:

.custom-logo > svg {
    fill: <your desired color>;
}

Answer №2

All it takes is a few adjustments...

  • Eliminate the inline styling from the svg element
  • Replace the svg tag with
    <svg width="24" height="24" .... ></svg>
  • Include these lines in your CSS
    span.logo > svg > path {fill: <your color>;}
  • To modify the color of the svg on form-control focus, use this method
    .form-control:focus + span.logo svg path{fill:<your color>;}

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

Guidelines for redirecting a page after a jQuery ajax call is made?

I'm working on a login form code and facing an issue where, after the statement is true, it doesn't redirect to the home page. Instead, it just displays the home page on my index page. How can I redirect jQuery Ajax to another page after the sta ...

Discover the impact of images.google.com on enhancing your image gallery

I am currently working on creating a website that features an image gallery. When a user clicks on a thumbnail, I want a hidden div to slide out and display more information about the image, possibly even including a slideshow. After extensive searching o ...

Issue with external JavaScript file being unresponsive on mobile browser

Hello everyone, hope you're having a great afternoon or evening I've encountered an issue with mobile browsers like Chrome Mobile and Kiwi where the external js file is not visible in the html file. The script.js file looks like this: alert(&ap ...

Issues with a top navigation bar

I'm currently working on customizing a header menu to my liking but have limited experience with CSS. The header menu consists of two main items, each with a dropdown. I envision the first menu item to look like this upon hover: https://i.sstatic.net ...

Align images to the bottom of the gallery only if their heights differ

I'm currently working on an image gallery project and have encountered a problem. When all the image labels are of the same length, they align perfectly. However, if the label is longer than one line, it causes the image to move up instead of creating ...

Tips on transforming button-controlled tab pages in Bootstrap 2 to Bootstrap 3

I am currently in the process of upgrading my website from Bootstrap 2 to Bootstrap 3, and I have encountered an issue with a specific control that consists of multiple sets of tab pages controlled by toggle buttons. Here is an example of the functional c ...

Is there a way for this SVG graphic to adjust its size to fit its container without manual resizing

Click here to view the demo In the demo, there is an SVG star placed inside a div with specific width and height. I am looking for a way to make the graphics adjust automatically to fit the size of the wrapper div. Since it's a vector graphic, I beli ...

Unleash the power of attribute selectors in a SASS/SCSS list variable: a comprehensive guide!

This is a sample code snippet: $list: ( input[type="text"], input[type="name"], input[type="email"], textarea, select[multiple] ) !default; @each $value in $list { ...

Creating equal height nested columns in Bootstrap 3 Grid: ensuring all nested columns are uniform in height

Struggling to make sure all columns in Bootstrap 3 are the same height throughout the page? If you've managed to achieve this with 3 columns, like the example provided here, great job! However, the challenge arises when dealing with nested columns t ...

Conceal HTML code from being displayed on a mobile device

After successfully displaying an element on mobile, I am now trying to hide it on the same platform. While I know this can be achieved with CSS using the display:none property, I want to explore alternative methods that do not involve creating unique CSS r ...

A CSS pseudo-class similar to :empty that disregards hidden children

Are you familiar with the :empty pseudo-class? This pseudo-class targets elements that have no children at all. But is there a way to target elements that have no visible children (excluding those with display: none)? If such a pseudo-class doesn't e ...

Adjusting the height of the v-footer

I'm having trouble adjusting the height of the v-footer component. According to the documentation, I should be able to use the height prop, but when I try height="100px" or height="50%", the footer doesn't change. What could be causing this issue ...

Transmit data from list items in the HTML to a form

Based on my understanding, there are limited options available to style an <option> tag within a <select> dropdown and it appears quite plain. So I was thinking about creating a more visually appealing dropdown using <ul> <li> tags ...

navigate through laravel pagination to different pages

Is there a way to navigate to a particular page on the pagination? ...

Triggering scroll snapping in CSS based on a different user action than just scrolling

Take a look at this example: https://codesandbox.io/s/spring-wood-0bikbb?file=/src/styles.css Try this to recreate the issue: Click on the input at the top Scroll to the bottom, then click on an empty area Observe how the screen jumps back up to the top ...

Enable access to the child of Lages and apply CSS to disable it

My current code looks something like this: <label for="billing:postcode" class="required"><em>*</em>Zip/Postal Code</label> I am looking to hide the <em> element from displaying using CSS. How can I achieve this with the dis ...

The functionality of Anchor `<a>` tags is compromised in Chrome when using the hashtag symbol (#)

Below is the code I have implemented on my website: <li><a href="/explore/#Sound">Sound</a></li> (This menu is visible on all pages) <a id="Sound"><a> (This is on the specific page where I want to link to) I have at ...

Tips for eliminating annoying white space on petite gadgets with css programming?

Having an issue with my static html page where I am seeing white space on the right side when checking responsiveness. I have tried multiple solutions found here on stack overflow, including adding the following code: I attempted to add this inline: html ...

Refresh the React state at regular intervals

constructor(){ super(); this.state={ numbers : [1,2,3,4,1,2,3,4,1,3,1,4,12,2,3,2] }; } componentDidMount(){setInterval(this.updateNumbers(),5000);} updateNumbers() { console.log(this.props.newData); let numbers = this.state.nu ...

Displaying text on hover and showing a text box when a link is clicked using CSS and JavaScript

Hovering over the text will display "Edit," and clicking on it will reveal a text box. This function will be used to update content using ajax. HTML: <table> <thead> <tr> <th> Name </th> <th> Age </th> ...