Divergent behavior of SVG elements in Firefox versus Chrome with HTML5

I am trying to position a 'div' under a 'textarea' within an 'svg' and 'g' element. This works fine in Firefox, but not in Chrome.

When I apply a transform on the 'g' element, it moves correctly to the desired position. However, nested elements with the "class" property are not positioned correctly. For example, a single 'i' element without children works well, but a 'span' does not.

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<svg id="svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display: inline; width: inherit; min-width: inherit; max-width: inherit; height: inherit; min-height: inherit; max-height: inherit; position: fixed;" version="1.1">
<g id="g1" transform="translate(130,30)">
<foreignObject x="0" y="0" width="150" height="150" overflow="visible" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
            <textarea style="background: white; color: black; border-radius:6px;border-style: solid; border-width: 3px;  width: 140px; font-size: 12px; resize: none; height: 50px">test</textarea>

            <div style="margin-top: -5px;height: 33px;">
                    <a href=""> 
                        <i class="fa fa-arrow-right"></i>
                       
                        <span class="fa-stack" title="Insert section">
                            <i class="fa fa-circle fa-stack-2x"></i>
                            <i class="fa fa-arrow-right fa-stack-1x fa-inverse"></i>
                        </span>
                    </a>
                </div>
</foreignObject>
</g>
</svg>

<svg id="svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display: inline; width: inherit; min-width: inherit; max-width: inherit; height: inherit; min-height: inherit; max-height: inherit; position: fixed;" version="1.1">
    <g id="g1" transform="translate(130,30)">
        <foreignObject x="0" y="0" width="150" height="150" overflow="visible" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
            <textarea style="background: white; color: black; border-radius:6px;border-style: solid; border-width: 3px;  width: 140px; font-size: 12px; resize: none; height: 50px">test</textarea>

            <div style="margin-top: -5px;height: 33px;">
                    <a href=""> 
                        <i class="fa fa-arrow-right"></i>

                        <span class="fa-stack" title="Insert section">
                            <i class="fa fa-circle fa-stack-2x"></i>
                            <i class="fa fa-arrow-right fa-stack-1x fa-inverse"></i>
                        </span>
                    </a>
                </div>
        </foreignObject>
    </g>
</svg>

Run the fiddle on both browsers to see the problem I mentioned: Fiddle

Here are the screenshots for reference:

Firefox Screenshot: Chrome Screenshot:

Thank you in advance o7

EDIT1:

It seems like a bug in Chrome. You should report this issue on their bug-tracker. When inspecting the element, the bbox is drawn correctly, but the actual element appears completely off.

In response to Kaiido's answer, it appears to be a Chrome-specific issue as there have been multiple instances of SVG-related problems with Chrome. Another interesting point is that the icon's positioning depends on the textarea's height. For example, if I set the height of the textarea to 200px, the icon will be further down as if an invisible textarea were above it.

Answer №1

See if you can delete the following section from the script.

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

Guide to arranging an object in ascending order based on a key's value using JavaScript

Is there a way to sort the following values: 1, 99, 1, 50 in javascript? Given the input: var map = {test:1, test2:99, test3:1, test4: 50} The desired output is: {test2:99, test4:50, test3:1, test:1} This is the approach I have attempted: function sort ...

Learn the proper way to refresh a post by using the F5 key in order to show a new get

Let me describe the issue I'm facing today. Currently, I am posting a message in my database and then performing a GET request in the same component to display the data sent just before. The problem is that every time I have to manually refresh the ...

Is it possible to create Excel documents containing statistical graphs and pie charts by utilizing PHP and SQL?

I have a database filled with statistical data that I want to export into an excel file. Can anyone recommend any popular libraries or scripts for generating excel files? Additionally, I am interested in displaying some of the dry numerical data in p ...

Hover over the Div element for inline effect

Hello all, I am currently working on running a while loop from a database to show different records. The twist is that these records are displayed as images, which makes it tricky to customize using standard CSS. To work around this, I'm implementing ...

Locate the image in the table by searching for the alt attribute and then show the entire row

I am looking to use the alt attribute of images in a table to search and display the entire row using javascript or jquery. <div class="input-group"> <span class="input-group-addon">Filter</span> <input id=& ...

Sort Messages By Date Created

While using Vue, I encountered a general JavaScript question. I am fetching cat messages from an API for a chat interface. The initial call returns an array of objects where each object represents a chat message: data: [ {id: 1, created_at: "2022-05 ...

Continuously spinning loading icon appears when submission button is triggered

We are currently experiencing some issues with our mobile forms. Our users utilize a mobile form to submit contact requests, but the problem arises when they hit 'submit' - the loading icon continues to spin even after the form has been successf ...

Having trouble with JQuery Draggable in FireFox only working in an iFrame? Learn how to set the ViewPort to fix

Having trouble with jQuery UI Draggable in FireFox 33.0.2: I followed the example code, but it doesn't seem to be working. The scripts are running, CSS classes are added, event bindings are in place, but dragging won't work. I noticed that when ...

Omit the <span> tag when exporting to XLS format

Currently, I have a functioning jQuery DataTable that utilizes the TableTools plug-in and includes <span> elements in one of the columns for each row. When clicking on the export button, my goal is to exclude or hide the <span> elements from t ...

Guide on utilizing multiple ng-apps alongside multiple controllers

Having trouble accessing controller values in different ng-apps? Here's a setup with two ng-apps and their controllers, where you may encounter errors when trying to access the value of one controller in another. Need some assistance with this issue. ...

jQuery AJAX call failing to return to page

Currently, my form is set up to upload multiple text fields and a file to a PHP script for saving. The script successfully saves the file and text fields to an SQL database. At the end of the PHP script, I have the following code snippet: ('state&apo ...

What are the best methods for implementing runtime type checking in JavaScript?

Utilizing either TypeScript or Facebook's Flow (type), I am empowered to statically assign types to variables like this: function add (x: integer, y: integer) { ... } Both TypeScript and Flow are able to identify and prevent incorrect invocations su ...

Implementing AJAX functionality in Codeigniter modulesTo integrate AJAX capabilities within Codeigniter modules

I am currently working on a webpage using the CodeIgniter framework. I am looking to integrate a 'show more' button that will utilize 'ajax.php' to retrieve data from the database and dynamically display it on the site. I prefer for thi ...

I attempted to implement an AJAX function, but unfortunately, it is not displaying any output

I attempted to implement an AJAX function but the output is not displaying anything. var ajaxFunction = function(url, method, data = "") { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { ...

Error: The function referenced is not defined when the page loads

Trying to incorporate two different script tags in a single HTML page has been quite a task for me. The first script tag contains the location of a JS file that I need to use for a specific function, while the second script tag is where I have written anot ...

Displaying or hiding table columns in Vue.js Element-UI el-table based on screen width: a step-by-step guide

Here is my code snippet for generating a table: <el-table :data="tableData" empty-text="No data to display :( " v-if="window.width > 855"> <el-table-column v-for="column in tableColumnsMd" :key=&q ...

Why isn't my Jquery click event able to download the csv file?

Initially, I was able to export a csv file using the html onclick element. However, when I switched to a jquery click event, the functionality stopped working. I don't understand why, as I believe the same function is being called. The Export.Expor ...

Creating a static file for deployment: A step-by-step guide

Currently, my node and webpack configuration allows me to run the dev-server and work on my application. However, I am facing issues in generating the static bundle.js file required for deployment on my website. I need help configuring my webpack.js file ...

The React Callservice script is failing to fetch the required data from the Node.js script responsible for making the API call

Recently, I decided to create a basic webpage using React.js to display data fetched from an API. Although the project is intended to be straightforward, my lack of recent development experience has led to a perplexing issue that I can't seem to resol ...

Update elements dynamically using JSX

I have an array called data.info that gets updated over time, and my goal is to replace placeholder rendered elements with another set of elements. The default state of app.js is as follows: return ( <Fragment> {data.info.map((index) =&g ...