How to resize/style the HTML content?
Iven2132 opened this issue · 11 comments
Question
How to resize/style the HTML content? for example, I want to make the HTML content small. currently, when I try to wrap parse(htmlContent) into a div and give it height and width it's not making the HTML content small. How to fix it?
<div>
<h1>HTML Content</h1>
<div style={{ width: '50%' }}>
{parse(htmlContent)}
</div>
</div>
@remarkablemark Hi, Not working
import React, { useState, useEffect } from 'react';
import parse from 'html-react-parser';
function ResizableHTMLContent() {
const [htmlContent, setHtmlContent] = useState('');
useEffect(() => {
fetch('/file.txt')
.then(response => response.text())
.then(html => {
setHtmlContent(html);
})
.catch(error => {
console.error('Error fetching HTML content:', error);
});
}, []);
return (
<div>
<h1>HTML Content</h1>
<div style={{ scale: 1 }}>
{parse(htmlContent)}
</div>
</div>
);
}
export default ResizableHTMLContent;
If you want it smaller, you need to use a scale smaller than 1 (e.g., 0.7)
Also, this question fits more at Stackoverflow than here since this is a styling question and not an html-react-parser question, so I'll be closing this issue
@remarkablemark I set it to 0.5 and also 0.7 it's not changing its size, please help🙏
@remarkablemark Hi, I still couldn't figure out the problem I posted on Stackoverflow no one replied can you please help me, Mark?
Can you share a CodeSandbox or JSFiddle of your issue?
@remarkablemark Yes, sure here is the CodeSandBox
@remarkablemark Sorry to hear that I made it public now https://codesandbox.io/p/devbox/w9n5ny?file=%2Fsrc%2FApp.jsx%3A9%2C14&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522cls3k4c8u0009336jdsa5lpyv%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522cls3k4c8r0003336jmqfwi7h9%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522cls3k4c8s0006336jjx8nn9ki%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522cls3k4c8t0008336jec1ohvzs%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522cls3k4c8r0003336jmqfwi7h9%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cls3k4c8r0002336jv2kyckfe%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A9%252C%2522startColumn%2522%253A14%252C%2522endLineNumber%2522%253A9%252C%2522endColumn%2522%253A14%257D%255D%252C%2522filepath%2522%253A%2522%252Fsrc%252FApp.jsx%2522%257D%255D%252C%2522id%2522%253A%2522cls3k4c8r0003336jmqfwi7h9%2522%252C%2522activeTabId%2522%253A%2522cls3k4c8r0002336jv2kyckfe%2522%257D%252C%2522cls3k4c8t0008336jec1ohvzs%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cls3k4c8t0007336j75evqk9i%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_PORT%2522%252C%2522taskId%2522%253A%2522dev%2522%252C%2522port%2522%253A5173%252C%2522path%2522%253A%2522%252F%2522%257D%255D%252C%2522id%2522%253A%2522cls3k4c8t0008336jec1ohvzs%2522%252C%2522activeTabId%2522%253A%2522cls3k4c8t0007336j75evqk9i%2522%257D%252C%2522cls3k4c8s0006336jjx8nn9ki%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cls3k4c8s0004336jezag6wkf%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%257D%252C%257B%2522id%2522%253A%2522cls3k4c8s0005336jboqxzitu%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522cls3hs8v0000ldlh06nkidog2%2522%257D%255D%252C%2522id%2522%253A%2522cls3k4c8s0006336jjx8nn9ki%2522%252C%2522activeTabId%2522%253A%2522cls3k4c8s0004336jezag6wkf%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D
@remarkablemark Any idea how to fix it?
@remarkablemark Hi Mark, Do you need my code Github repo?
