CSS: Make DIV Center:

<style>
#root {
  display: grid;
  place-items: center;    /* 同时水平和垂直居中 */
  height: 100vh;          /* 使容器占满整个视窗高度 */
}
</style>
<div id="root"></div>

Make elements in div on the one line

App.js

      <div className="controls">
        <input type="file" accept="image/*" onChange={handleImageChange} className='input-file' />
        <button onClick={handleScreenshot}>Screenshot</button>
      </div>

App.css:

.controls {
  display: flex;
  align-items: center;
  gap: 10px; /* 间距可调整 */
  margin-top: 10px;
}

Save DIV As An Image

App.js

import html2canvas from 'html2canvas';

  const handleScreenshot = () => {
    const container = document.querySelector('.image-container');
    html2canvas(container).then(canvas => {
      const link = document.createElement('a');
      link.href = canvas.toDataURL('image/png');
      link.download = 'wallpaper.png';
      link.click();
    });
  };
Categories: Web

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
0
Would love your thoughts, please comment.x
()
x