简体   繁体   中英

How to change text size from pixels to vw in this code?

Is there any easy way to change text size from pixels to vw in this code?

Tried in css - no results.

const elem = document.querySelector("div");
const textEl = elem.querySelector("p");
const createBlotterText = () => {
const text = new Blotter.Text(textEl.innerHTML, {
family: "sans-serif",
weight: 700,
size: 100,
paddingLeft: 100,
paddingRight: 100,
paddingTop: 100,
paddingBottom: 100,
fill: "white"
  });

CODEPEN

Use this code for size, size code mentioned inside * mark. This code help you to convert px to vw.

const createBlotterText = () => {
const text = new Blotter.Text(textEl.innerHTML, {
  family: "sans-serif",
  weight: 700,
  *size: 100vw/500px,*
  paddingLeft: 100,
  paddingRight: 100,
  paddingTop: 100,
  paddingBottom: 100,
  fill: "white"
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM