Comments (4)
The cause of this is simple, root font size is defined as 24px in ReactUnity instead of browser's 16px. This was done with the thought that games usually require bigger fonts.
The font size is defined in useragent stylesheet. It can be easily overridden with:
:root {
font-size: 16px;
}
When we add a useragent stylesheet for browser rendering compatibility, this should be easy to fix.
from core.
Changed default font size to 16px in v0.14.0
from core.
Additional information:
- em Unit: The em unit allows setting the font size of an element relative to the font size of its parent. When the size of the parent element changes, the size of the child changes automatically.
- rem Unit: The rem is based upon the font-size value of the root element, which is the element. And if the element doesnโt have a specified font-size, the browser default value of 16px is used. So here only the value of the root is considered, and there is no relation with a parent element.
as for the reactUnity example, no CSS style or root of HTML has been changed
from core.
Relative em scaling seems to work properly (except for the oversized starting size)
HTML
<html>
<body>
<span>Chrome</span><br/>
<span style="display: flex; flex-direction: column; font-size: 2em">
2em text
<span style="display: flex; flex-direction: column; font-size: 2em">4em text
<span style="display: flex; flex-direction: column; font-size: 2em">
6em text
</span>
</span>
</span>
</body>
</html>
ReactUnity
import { Renderer } from '@reactunity/renderer';
function App() {
return <div>
<text>ReactUnity</text>
<span style="font-size: 2em">
2em text
<span style="font-size: 2em">4em text
<span style="font-size: 2em">
6em text
</span>
</span>
</span>
</div>;
}
Renderer.render(<App />);
from core.
Related Issues (20)
- Consider supporting 2023.2.0f1 HOT 1
- How get react global value from c#? HOT 4
- [UGUI] Performance improvement for non rounded elements HOT 2
- [UGUI] Pointer events are not consistent if parent have none and children have auto HOT 3
- Image Quality/Resolution HOT 5
- onMouseDown, onPointerDown and probably more events do not work as intended HOT 5
- Auto-Reload after changes in code are not reflected or automaticaly updated. HOT 1
- Created canvases should inherit properties from the main canvas HOT 1
- What's the best practice to use Router? HOT 2
- Chinese didn't render in ReactUnity canvas HOT 2
- Inconsistent element rendering HOT 4
- [CSS] "width: 100%" seems to not work inside of Unity HOT 1
- compare with react-unity-webgl HOT 1
- TypeScript is missing the definition of `direction` prop in `scroll` element HOT 1
- UI Toolkit renderer is missing css properties like `background-size` HOT 2
- BUG [TypeScript] `UnityEngine.Networking` has no exported member `UnityWebRequest` HOT 1
- Hot reloading? HOT 3
- Websockets? HOT 4
- [BUG] UI Toolkit `:active` does not work HOT 2
- [BUG] `decodeURIComponent` does not work in Android HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.