The transformation does not occur again when the window is resized

After seeing a question on How to make svg RTL
I attempted to make my svg RTL using:

transform: translate(100%, 0) scale(-1, 1);  

However, I noticed that when resizing my browser window, the transform is not properly applied and the line origin shifts!
Here is an example showcasing this issue
To reproduce:
1- Change the window size (perhaps make it larger), observe how the line origin deviates from 0 0
2- Use inspect element on the line, uncheck and then check the "transform" in the CSS class, the element returns to its correct position

It is clear that the transform is not being applied correctly upon resizing.

Answer №1

One effective technique to specify the position and size of an SVG viewport is by using the viewBox attribute:

function App() {
  return (
    <div className="App">
      <div>
        To observe the effect, adjust the browser window size and witness how the line's position deviates from 0, 0.
      </div>
      <svg viewBox="0 0 200 200" vector-effect="non-scaling-stroke">
        <g className="svgRTL">
          <path
            stroke="green"
            strokeWidth="3"
            fill="none"
            d="M 0 0 L 100 100"
          />
        </g>
      </svg>
    </div>
  );
}

https://codesandbox.io/s/svg-origin-change-testcase-zkyfe?fontsize=14

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

Utilize Vue.js to sort by price bracket and category

Hello, I am currently new to working with Vue.js and I am attempting to create two filters - one for price range and the other for genre. Any guidance or assistance would be greatly appreciated. Below is a snippet of my code: ul class="filter-wrapper"&g ...

Stylish CSS popup backdrop

I have very limited CSS knowledge and struggle with the syntax, but I am trying to customize my Wikipedia experience using Chrome and the Stylish addon. I found some code online and modified it to create a dark theme, but now I'm stuck because I need ...

Should I create CSS rules for different screen sizes or should I dynamically render components based on the screen size?

As I delve into learning React, I find myself unsure about the most effective approach to make websites responsive. Currently, I am utilizing Semantic UI React as my CSS Library. While everything displays perfectly on desktop, I encounter some issues when ...

"Enhance your website's loading speed with the Google Page Speed Up

Hi, I've been using the Google PageSpeed Module and have created a .htaccess file to optimize my website (www.anetoi.com). I tried using combine_css to merge my CSS files but it didn't work as expected. I followed Google's instructions but s ...

What is causing the network tab requests not to appear in the browser when I am utilizing NextJS SSR?

I'm currently focusing on a React project that utilizes SSR for SEO benefits. Can you explain how NextJS handles SSR? I'm curious about where the requests originate from if not the browser. Appreciate your help! ...

What methods can be used to keep divs from breaking onto separate lines?

My approach involves using divs to mimic a table structure. Below is the header section of this table: <div id="table-header"> <div id="header-row"> <div class="rate-rule-column s-boarder"> ...

The `Home` object does not have the property `age` in React/TypeScript

Hey there, I'm new to React and TypeScript. Currently, I'm working on creating a React component using the SPFX framework. Interestingly, I'm encountering an error with this.age, but when I use props.age everything seems to work fine. A Typ ...

What is the best way to create transitions for item entry and exit in ReactJS without relying on external libraries?

I am looking to create an animation for a toast notification that appears when a user clicks on a button, all without the use of external libraries. The animation successfully triggers when the toast enters the screen upon clicking the button. However, I e ...

The scrolling element mirrors the movement of the scrolling window

Can you help me understand how to create a scrolling element that follows the scrolling of the window? I want the element to scroll down when the window reaches the end, and scroll up when the window is at the top. I tried implementing this functionality ...

The module 'react/jsx-runtime' could not be located within the directory '/client/node_modules/@mui/icons-material' during the Docker setup process

"I've been encountering an error while trying to run my Dockerized React application, even after specifying the package installation command in my Dockerfile. I also tried installing the jsx-runtime package but it didn't solve the issue. If ...

The geocoder-autocomplete feature in ReactJS is now experiencing a sudden Network Error in Firefox

I followed the tutorial provided by HERE and successfully implemented the solution for street address validation using ReactJS and HERE geocoder autocomplete. Everything was working fine on Firefox and Chrome until a few weeks ago when it suddenly stopped ...

Tips for showing more rows by clicking an icon within an Angular 2 table

When I click on the plus (+) button in the first column of each row, only one row expands. How can I modify it to expand multiple rows at a time? Thanks in advance. <div> <table class="table table-striped table-bordered"> <thead> ...

The Process of Developing Applications

As a newcomer to web development, I have a solid understanding of HTML and CSS, and am learning JavaScript. When considering creating a web app, would it be better for me to focus on writing the functionality in JavaScript first before integrating it int ...

Looking for assistance in setting up a straightforward TypeScript Preact application

I recently started exploring preact and I'm attempting to create a basic app using typescript in preact. I've noticed that their default and typescript templates include extras like jest and testing, which I don't necessarily require. Althou ...

Card columns with dropdown extending into adjacent column

Encountering a strange problem with the card-columns layout in Bootstrap when using dropdown menus within the cards. The issue arises when the dropdown-menu divs of the lower cards bleed into the next column, despite appearing in the correct position. Thi ...

Issue with Hover Effect for Input Type in Submit Form in HTML and CSS

In the following HTML code, a form is displayed inside a card HTML. The form appears after an onlick function which functions correctly. However, the submit button in the form below does not display a hover effect. <!-- Update details form here --> ...

The put method is not recognizing the Axios callback function

Having an issue with Axios callback not working when updating a MySQL database. The data gets updated successfully, but the callback function doesn't work. Strangely, post, delete and get callbacks are working fine. Here is the code snippet: Frontend ...

Is it possible to access an external website by clicking on a link within a DIV element?

I have a basic website set up like this sample.php <html> <head></head> <body> <a id="myLink" href="http://sample.com">Click!</a> </body> </html> I displayed this website within a DIV-Container on a ...

Filtering FieldSelector options in react-querybuilder: A step-by-step guide

I am currently working on a task to eliminate the fields from FieldSelector that have already been utilized. In my custom FieldSelector component, let's assume there are fields A, B, C, D, E available. If A & B have been used, they should not be ...

What is the best way to align this button next to the text and header on the page?

I'm struggling to position this button next to the paragraph element instead of below it. I want them both on the same line. <div class="up"> <div class="ban"> <div class="act"> <h2>Joi ...