Replace the svg with text in the navigation menu

Can an SVG image be converted to text? I recently purchased a Bootstrap template and have some questions.

In the navigation bar of my website, the text changes from white to black when scrolling down. Is it possible to change my logo to text as well? If so, how can this be achieved?

https://i.sstatic.net/PsWqE.jpg

*If my logo is white, it becomes invisible after scrolling down. What should I do in this case?

Answer №1

To change the color of an image from black to white or vice versa, you can utilize the CSS filter property along with its invert() function.

body {
  font: 13px Verdana;
}

.div {
  display: flex;
  align-items: center;
  padding: 10px;
}

.before {
  background: red;
  color: white;
}

img {
  margin-left: 30px;
}

.before img {
  filter: invert(1)
}

.after {
  border: 1px solid red
}
Before Scroll
<div class="div before">
  <h2>Boomerange</h2>
  <img src="https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/vote.svg" width="100">
</div>
<br><br> After Scroll
<div class="div after">
  <h2>Boomerange</h2>
  <img src="https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/vote.svg" width="100">
</div>

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

Embrace the strange quirks of each individual

I attempted to find a simple solution for creating a box within a class. However, I encountered an issue where it only displayed the first element in the array. Upon echoing out the $values variable, the entire CSS code was returned and I attempted to plac ...

Looking to showcase website HTML code by simply clicking on a banner image?

I am looking to implement a feature where banner HTML code is displayed in a popup on website when the banner is clicked. For instance, an example of a banner could be: <img src="https://myweb.com/images/banners/1.gif"> Upon clicking the banner im ...

The dropdown menu from React Bootstrap is only partially visible when used within the datagrid

They say a picture is worth a thousand words, and what's bothering me now is this predicament: https://i.sstatic.net/UGxyi.jpg I apologize for the blurred text, but I can't disclose much due to company policy... As you can see in the screenshot ...

D3 Treemap for handling extensive sets of data

I am uncertain if there exists a method to incorporate the desired feature. I am seeking a solution similar to zoomable treemaps, but to initially load a limited number of child levels and then dynamically add more child nodes without requiring a node clic ...

sophisticated HTML navigation bar

I am looking for a way to create a menu where the drop-down items overlay the rest of the menu when the screen width is small. Here is my current code: nav{ line-height:100%; opacity:.9; }nav ul{ background: #999; padding: 0px; border-radius: 20px; ...

I am interested in showcasing a card when it is hovered over

I am having trouble with a hover effect to display a hidden card. I have two div elements, one is labeled single-album and the other hide. I used the + selector to set the hide div to display none initially, but the hover effect is not working as expecte ...

How to target the last li element with a custom class using CSS?

I am working with a dynamic list that is populated from a SQL database. The list consists of items with different classes, such as "range1" and "range2". I need to select the last item in the list that has the class "range1", but using nth-child won't ...

How can I enable two-finger scrolling on mobile web browsers?

I am currently tackling a project that involves dragging operations on a canvas, making scrolling with a single finger impractical. My goal is to enable scrolling using two fingers instead. After testing different touch-action values, I discovered that pi ...

Trouble with CSS rendering on Sharepoint in Edge Browser - Dealing with SEC7111 Issue

Recently, I was moved to a Windows 10 VM from Windows 7 and I encountered an issue with displaying a site for my team at work properly in Edge. A WebPart linking to CSS was showing everything as one large list instead of a table with dropdowns. Oddly enoug ...

The floating label failed to appear when the input was focused

After searching online, I came across an example of how to create a floating label. I followed the instructions exactly as provided in the example, but when I tested it on my website, it did not work the way it was supposed to. The label would disappear wh ...

Create a soft focus on the background sans any filters

I am in the process of developing a website and have implemented code to blur out the background: CSS #background{ background: url(img/bg.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o ...

Crafting a secretive and subtle side menu that pops out when triggered

My website features a hidden side menu that slides out when the main div is hovered over. The challenge arises when I want the side menu to remain visible when interacting with its elements, while still hiding when both the main div and side menu are not b ...

Advancing background gradients with CSS

Looking for help with CSS to create specific effects? I have the gradient covered, but struggling with rounded corners in some areas. Any suggestions? Check out this blue background and also this blue background Appreciate any advice you can provide. Tha ...

Reset the value of the input type file when the modal is closed and ensure that the Save All Changes button is deactivated

Hey there! Working on a simple project and trying to incorporate a neat trick in my app. I want to achieve the following: Clear the input type file value when the modal is closed. Essentially, if the user decides to cancel the upload and closes the modal, ...

Converting CSS styles with media queries and handling other special cases into a PHP array

Need help converting a CSS file to a PHP array. Here is the code snippet I am using: function convertCssToPhpArray($css_str) { $css = array(); // TODO: handle external css files $css_str = preg_replace('/(@import\s+["\'].+ ...

How should one properly adjust for a placeholder element during ng-animate implementation?

Check out my Plunker project here: http://plnkr.co/edit/Pl5KaBkFouadAGKSB0Mt?p=preview On this page, a message with my name pops up every 3 seconds. However, during the transition between messages, both the actual message div and the placeholder div are b ...

Cease the video playback in the modal when the modal is closed

I've attempted several solutions found on stack overflow, but none of them seem to be effective. When I replace the video tag with an iframe, some solutions work, but the video autoplays again, causing issues with the solution. <div class="ico ...

Organizing playing cards in a React JS application

As a beginner just starting out with React JS, I'm working on arranging cards in a medium size for my application. I came across a card design that I like and I'm seeking help to achieve something similar. Any assistance would be greatly apprecia ...

Tips on how to showcase list items in a horizontal manner while maintaining consistent spacing and ensuring they are

I have a list of items denoted by the "li" tag, and I am looking for a way to display them horizontally or in a neat format. Below is the HTML code snippet: <!doctype html> <html lang="en" ng-app="app"> <head> ... </head> <bo ...

Why does Chrome DevTools evaluate JavaScript before recalculating styles?

According to an article, CSS is considered render-blocking, so JavaScript will evaluate after constructing a CSSOM (also known as recalculating styles in dev tools). However, it appears in Chrome dev tools that JavaScript is evaluated before CSSOM. Why is ...