English 中文(简体)
防止在电网布局上安装的线性突破
原标题:Prevent line-breaks copied to the clipboard in grid layout

Im利用I的专用超文本结构开展工作。 我通过安全总局安排了视像适合我的需要的电网布,但在复制文本时,我不希望的每个区块之间增加一条线。

Below is an example:

div {
  display: inline-grid;
  grid-template-columns: repeat(5, auto);
}
span { display: block }
<div>
  <span>1</span><span>+</span><span>3</span><span>=</span><span>4</span>
</div>

With Chromium 79, when selecting, copying to the clipboard and then pasting it somewhere, the result is as follows:

1
+
3
=
4

在Fox 72号大火中,我收到了我想要的东西:

1+3=4
问题回答

我使用了这种方法,并采用了React和MUI(但不需要):

  1. Add an invisible special character as the new-line replacement at the end of each row such as:
<Box
    sx={{
    color:  transparent ,
     &::selection : {
        backgroundColor:  transparent ,
    },
    }}
>
    ↵
</Box>
  1. Then on the copy event:
  const onCopy = async () => {
    const text = await navigator.clipboard.readText();
    const fixed = text
      // Split lines
      .split( ↵ )
      // Replace new line from grid cells
      .map((l) => l.replace(/
?
/g,    ).replace(/ +/g,    ).trim())
      // Rejoin the lines
      .join( 
 );
    await navigator.clipboard.writeText(fixed);
  };

遴选内容给你带来任何伤害,但仍增加了一个小的解决办法,以解决:

<html>
<head>
<style>
div {
  display: inline-grid;
  grid-template-columns: repeat(5, autoiii;
  display:inline-block;
}

</style>
</head>
<body>
<div>
  <span>1</span>
  <span>+</span>
  <span>3</span>
  <span>=</span>
  <span>4</span>
</div>
</body>
</html>

iii





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...