玩套路吗

文章 评论 浏览 29

玩套路吗 2025-02-10 00:15:16

我认为发布消息没有什么关系,我的错误是在使用效率上而不是on load上这样做:

const post = () => {
    try{
        let frame = document.getElementById('storage')
        frame.contentWindow.postMessage({user: 'name', password: 'pass'}, storageUrl);
        console.log('posted')
        } catch (e){
            console.log(e)
        }
}
return (
    
        <div className="pt-100 pb-70">
            <div className="container">
            <iframe id='storage' src='https://my.domain.com' style={{width: '100%', height: '100vh'}} onLoad={post}/>
            </div>
        </div>
)

Figured the error had nothing to with posting a message, my mistake was doing it on useEffect instead of an onload:

const post = () => {
    try{
        let frame = document.getElementById('storage')
        frame.contentWindow.postMessage({user: 'name', password: 'pass'}, storageUrl);
        console.log('posted')
        } catch (e){
            console.log(e)
        }
}
return (
    
        <div className="pt-100 pb-70">
            <div className="container">
            <iframe id='storage' src='https://my.domain.com' style={{width: '100%', height: '100vh'}} onLoad={post}/>
            </div>
        </div>
)

无法在交叉起源上发布消息

玩套路吗 2025-02-09 23:38:41

我有MacBook M2,我偶然发现了这个问题。
试图通过:

python -m pip install --upgrade pip

目前尚未解决我的问题,

pip install --upgrade pip

我尚未解决我的问题

,我降级到以前的PIP:

pip install -U pip==23.2.1

您可以随时从pypi.org/检查版本历史记录

I have macbook m2 and I've stumble on this issue.
Tried to update pip manually by:

python -m pip install --upgrade pip

and

pip install --upgrade pip

both did NOT solve my problem

For now, I downgrade to previous version of pip by:

pip install -U pip==23.2.1

Anytime you can check the version history from pypi.org/

有一个错误检查最新版本的PIP

玩套路吗 2025-02-09 14:53:46

您的问题是此行如果(J-I+1&lt; k)J ++;

考虑以下代码:

int j=0;
int k=10;
while(j<s.length()){
    if(j-i+1<k)
        j++;

上面的代码将始终导致j内部的值增加并从1(而不是0)开始,这也将使您的子线在另一端溢出1。如果(J-I+1&lt; k)J ++; 在您的代码中降低,我们可以通过简单地移动行来解决此问题。但是,我们知道j必须加上每个循环,因此,即使(J-I+1&lt; k)>:

while(j<s.length()){
    if(j-i+1==k){
        String substr=s.substring(i,j+1);
        if(seen.contains(substr)){
             repeated.add(substr);
         }
         else{
             seen.add(substr);
        }
        i++;
        j++;
    }
//Incriment j here after checking the sequence
    j++;
}
return new ArrayList(repeated);

下一个问题是, 即使使用您正在尝试在两个语句中增加j ++;在两个只会导致您的代码跳过值的语句中进行修复,只需删除j ++; 从您的其他if语句类似:

while(j<s.length()){
    if(j-i+1==k){
        String substr=s.substring(i,j+1);
        if(seen.contains(substr)){
             repeated.add(substr);
         }
         else{
             seen.add(substr);
        }
        i++;
//Delete the following line
        //j++;
    }
//Incriment j here after checking the sequence
    j++;
}
return new ArrayList(repeated);

现在您的方法将正确返回重复序列而无需异常。

请注意,您可以摆脱i变量,使您的代码更加易读,更简单,并编辑您的时循环以为您完成工作(j&lt; = s.lt; = s.length ()-k){,请注意&lt; =-k在结尾处,确保我们无法完成界限,从而通过完成界限。结束前循环10个字符:

int j = 0;
int k = 10;
//find every possible sequence that is at least 10 characters long using "j <= s.length()-k"
while (j <= s.length()-k){
    String substr = s.substring(j, j + k);
    if (seen.contains(substr)){
        repeated.add(substr);
    }
    else{
        seen.add(substr);
    }
    j++;
}
return new ArrayList(repeated);

Your issue is this line if(j-i+1<k)j++;

Consider the following code:

int j=0;
int k=10;
while(j<s.length()){
    if(j-i+1<k)
        j++;

The above code will always cause the value of j inside your while loop to increment and start at 1 (not 0) which will cause your substring to overflow by 1 at the other end as well. We can fix this by simply moving the line if(j-i+1<k)j++; to be lower down in your code. But also, we know j has to be incrimented every loop, so there in no point even using if(j-i+1<k):

while(j<s.length()){
    if(j-i+1==k){
        String substr=s.substring(i,j+1);
        if(seen.contains(substr)){
             repeated.add(substr);
         }
         else{
             seen.add(substr);
        }
        i++;
        j++;
    }
//Incriment j here after checking the sequence
    j++;
}
return new ArrayList(repeated);

The next issue is that you were attempting to increment j++; inside both of your if statement which will only cause your code to skip values, to fix this simply remove j++; from your other if statement like so:

while(j<s.length()){
    if(j-i+1==k){
        String substr=s.substring(i,j+1);
        if(seen.contains(substr)){
             repeated.add(substr);
         }
         else{
             seen.add(substr);
        }
        i++;
//Delete the following line
        //j++;
    }
//Incriment j here after checking the sequence
    j++;
}
return new ArrayList(repeated);

Now your method will correctly return the duplicate sequences without an out of bounds exception.

Note that you can make your code even more readable and simpler by getting rid of the i variable, and editing your while loop to do the work for you while (j <= s.length()-k){, note the <= and -k at the end that ensures we do not get any out of bounds exceptions by finishing the loop 10 characters before the end:

int j = 0;
int k = 10;
//find every possible sequence that is at least 10 characters long using "j <= s.length()-k"
while (j <= s.length()-k){
    String substr = s.substring(j, j + k);
    if (seen.contains(substr)){
        repeated.add(substr);
    }
    else{
        seen.add(substr);
    }
    j++;
}
return new ArrayList(repeated);

解决问题时,运行时错误正在出现

玩套路吗 2025-02-09 03:50:11

两种方式:

1。

for k in arr:
    print(k,arr[k].val,arr[k].count)
for k, node in arr.items():
        print(k,node.val,node.count)

Two ways:

1.

for k in arr:
    print(k,arr[k].val,arr[k].count)
for k, node in arr.items():
        print(k,node.val,node.count)

如何打印以下自定义的数据,该数据在字典中存在?

玩套路吗 2025-02-08 11:04:25

这是一种可能起作用的方法。

对于您的公式,请用IFERROR包裹Importrange,然后具有触发器,例如(isblank(...),您的其他公式。 让我

知道这是否有意义。

Here's one approach that might work.

For your formulas, wrap the IMPORTRANGE with IFERROR and then have a trigger like IF(ISBLANK(...) for your other formulas. Reference a cell further down in your dataset (e.g. A200) that will be nonblank if your initial IMPORTRANGE completed properly.

Let me know if that makes sense.

在Google表中,暂停公式计算直到应用程序脚本完成

玩套路吗 2025-02-07 23:14:41

如果您使用androidx.compose.material3.typography,将有两种方法:
首先是复制每种样式并更改字体系列。

fun createTypography(parent: Typography, fontFamily: FontFamily): Typography{
return Typography(
    parent.displayLarge.copy(fontFamily = fontFamily),
    parent.displayMedium.copy(fontFamily = fontFamily),
    parent.displaySmall.copy(fontFamily = fontFamily),
    parent.headlineLarge.copy(fontFamily = fontFamily),
    parent.headlineMedium.copy(fontFamily = fontFamily),
    parent.headlineSmall.copy(fontFamily = fontFamily),
    parent.titleLarge.copy(fontFamily = fontFamily),
    parent.titleMedium.copy(fontFamily = fontFamily),
    parent.titleSmall.copy(fontFamily = fontFamily),
    parent.bodyLarge.copy(fontFamily = fontFamily),
    parent.bodyMedium.copy(fontFamily = fontFamily),
    parent.bodySmall.copy(fontFamily = fontFamily),
    parent.labelLarge.copy(fontFamily = fontFamily),
    parent.labelMedium.copy(fontFamily = fontFamily),
    parent.labelSmall.copy(fontFamily = fontFamily)
    )    
}

另一种方法是使用反思:

fun createTypographyReflection(parent: Typography, fontFamily: FontFamily): Typography{
val result = Typography()
Typography::class.java.declaredFields.filter { it.type == TextStyle::class.java }.forEach { field ->
    field.isAccessible = true
    val textStyle = field.get(parent) as TextStyle
    val modifiedTextStyle = textStyle.copy(fontFamily = fontFamily)
    field.set(result, modifiedTextStyle)
}
return result
}

If you are using androidx.compose.material3.Typography, there would be 2 approaches:
First one is to copy each style and change the font family.

fun createTypography(parent: Typography, fontFamily: FontFamily): Typography{
return Typography(
    parent.displayLarge.copy(fontFamily = fontFamily),
    parent.displayMedium.copy(fontFamily = fontFamily),
    parent.displaySmall.copy(fontFamily = fontFamily),
    parent.headlineLarge.copy(fontFamily = fontFamily),
    parent.headlineMedium.copy(fontFamily = fontFamily),
    parent.headlineSmall.copy(fontFamily = fontFamily),
    parent.titleLarge.copy(fontFamily = fontFamily),
    parent.titleMedium.copy(fontFamily = fontFamily),
    parent.titleSmall.copy(fontFamily = fontFamily),
    parent.bodyLarge.copy(fontFamily = fontFamily),
    parent.bodyMedium.copy(fontFamily = fontFamily),
    parent.bodySmall.copy(fontFamily = fontFamily),
    parent.labelLarge.copy(fontFamily = fontFamily),
    parent.labelMedium.copy(fontFamily = fontFamily),
    parent.labelSmall.copy(fontFamily = fontFamily)
    )    
}

the other way is to use reflection:

fun createTypographyReflection(parent: Typography, fontFamily: FontFamily): Typography{
val result = Typography()
Typography::class.java.declaredFields.filter { it.type == TextStyle::class.java }.forEach { field ->
    field.isAccessible = true
    val textStyle = field.get(parent) as TextStyle
    val modifiedTextStyle = textStyle.copy(fontFamily = fontFamily)
    field.set(result, modifiedTextStyle)
}
return result
}

如何以编程方式更改JetPack中的字体家族?

玩套路吗 2025-02-07 17:50:32

一个简单的解决方案是编写一个函数:

function generate_password {
    </dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12
}

然后,您的代码段变为:

sqlite variables.db "create table passwords (name TEXT PRIMARY KEY, value TEXT);"
sqlite variables.db "insert into passwords (name,value) values ('BOOKSTACK_MYSQL_ROOT', '$(generate_password)');"
sqlite variables.db "insert into passwords (name,value) values ('BOOKSTACK_MYSQL', '$(generate_password)');"
sqlite variables.db "insert into passwords (name,value) values ('BORG_PASSPHRASE', '$(generate_password)');"
# ...

A simple solution would be to write a function:

function generate_password {
    </dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12
}

Then, your code snippet becomes:

sqlite variables.db "create table passwords (name TEXT PRIMARY KEY, value TEXT);"
sqlite variables.db "insert into passwords (name,value) values ('BOOKSTACK_MYSQL_ROOT', '$(generate_password)');"
sqlite variables.db "insert into passwords (name,value) values ('BOOKSTACK_MYSQL', '$(generate_password)');"
sqlite variables.db "insert into passwords (name,value) values ('BORG_PASSPHRASE', '$(generate_password)');"
# ...

避免重复Bash中的变量设置

玩套路吗 2025-02-07 15:50:40

我在这里遇到了同样的问题,并且我发现,如果您的笔记本中存在错误,则imagej进入其“不活动”状态。每次发生此错误时,对我的修复似乎都在重新启动内核。

I had the same issue here, and I've found that if there is an error in your notebook at any point imageJ enters into its "Inactive" state. The fix for me seems to be restarting the kernel each time this error occurs.

ij.getVersion()为2.5.0/intactive

玩套路吗 2025-02-07 11:53:00

问题是我以32位的构建,用于64位应用。一旦基于本机X64编译器开发,它就起作用了。

The problem was I was building as 32 bit for a 64 bit application. Once building on native x64 compiler development, it worked.

链接到libxml2.lib文件的Windows,但找不到外部符号

玩套路吗 2025-02-06 17:19:13

该代码正在创建一个多行字符串(在每行末尾添加\ n)。如果您运行print(reper(table)),则输出是:

'\\begin{tabular}{cc}\n\\bf{Material} & \\bf{Roughness ($\\epsilon$)} \\\\\n\\midrule\nDrawn Tubing & 0.000005 \\\\\nCommercial Steel or Wrought Iron & 0.00015 \\\\\nAsphalted Cast Iron & 0.0004 \\\\\nGalvanized Iron & 0.0005 \\\\\nWood Stave & 0.0006-0.003 \\\\\nCast Iron & 0.00085 \\\\\nConcrete & 0.001-0.01 \\\\\nRiveted Steel & 0.003-0.03\n\\end{tabular}'

您可以使用()

table = (r"\begin{tabular}{cc}"
r"\bf{Material} & \bf{Roughness ($\epsilon$)} \\"
r"\hline "
r"Drawn Tubing & 0.000005 \\"
r"Commercial Steel or Wrought Iron & 0.00015 \\"
r"Asphalted Cast Iron & 0.0004 \\"
r"Galvanized Iron & 0.0005 \\"
r"Wood Stave & 0.0006-0.003 \\"
r"Cast Iron & 0.00085 \\"
r"Concrete & 0.001-0.01 \\"
r"Riveted Steel & 0.003-0.03"
r"\end{tabular}")

将领先的“ R”放在每个上行,以便将所有部分解释为RAW(请参见在这里)。

此外,由于未识别,我必须替换r“ \ hline”(包装?)。

The code is creating a multi line string (adding \n at the end of each line). If you run print(repr(table)), the output is:

'\\begin{tabular}{cc}\n\\bf{Material} & \\bf{Roughness ($\\epsilon$)} \\\\\n\\midrule\nDrawn Tubing & 0.000005 \\\\\nCommercial Steel or Wrought Iron & 0.00015 \\\\\nAsphalted Cast Iron & 0.0004 \\\\\nGalvanized Iron & 0.0005 \\\\\nWood Stave & 0.0006-0.003 \\\\\nCast Iron & 0.00085 \\\\\nConcrete & 0.001-0.01 \\\\\nRiveted Steel & 0.003-0.03\n\\end{tabular}'

You can construct a long raw line by using the ():

table = (r"\begin{tabular}{cc}"
r"\bf{Material} & \bf{Roughness ($\epsilon$)} \\"
r"\hline "
r"Drawn Tubing & 0.000005 \\"
r"Commercial Steel or Wrought Iron & 0.00015 \\"
r"Asphalted Cast Iron & 0.0004 \\"
r"Galvanized Iron & 0.0005 \\"
r"Wood Stave & 0.0006-0.003 \\"
r"Cast Iron & 0.00085 \\"
r"Concrete & 0.001-0.01 \\"
r"Riveted Steel & 0.003-0.03"
r"\end{tabular}")

Putting the leading "r" at every line, so that all portions are interpreted as raw (see here).

Furthermore, I had to replace the midrule by r"\hline ", as it was not recognised (package required?).

matplotlib无法渲染乳胶表

玩套路吗 2025-02-06 05:18:03

您的代码有一些错误,

int main() {

    char ch[] = "Welcome text in a separate line.";
    // char strWords[5][7]; <<<=== i would change to be larger that you need, just in case
    char strWords[20][20];
    int counter = 0;
    int a = 0;

    for (int i = 0; i < strlen(ch); i++) { // sizeof is wrong, you need strlen

        if (ch[i] == ' ') {
            strWords[counter][a] = '\0';
            counter++;
            a = 0;
        }
        else
        {
            //strWords[counter][a] += ch[i];
            strWords[counter][a] = ch[i]; // you do not need to try to concatenate, you are already walking down the buffer with 'a'
            a++;
        }

    }

    for (int i = 0; i < counter; i++) { // use 'counter' as it has the number of lines
       // since you 0 terminated the string you do not need to walk character by character

         cout << strWords[i] << "  ";

    }


    return 0;
}

您也没有检测到和终止最后一个单词(因为之后没有空间)。我会把它留给你。我显示的代码不会打印单词“行”。

您应该真正进行测试,以确保您不会溢出单词的长度或数量。

另外,理想情况下,您应该使用std :: Stringstd :: vector

注意 - 如果进行实验,您确实想通过char穿过char来输出您应该应该的字符串寻找终止的“ 0”字符并退出内部循环

A few things wrong with your code

int main() {

    char ch[] = "Welcome text in a separate line.";
    // char strWords[5][7]; <<<=== i would change to be larger that you need, just in case
    char strWords[20][20];
    int counter = 0;
    int a = 0;

    for (int i = 0; i < strlen(ch); i++) { // sizeof is wrong, you need strlen

        if (ch[i] == ' ') {
            strWords[counter][a] = '\0';
            counter++;
            a = 0;
        }
        else
        {
            //strWords[counter][a] += ch[i];
            strWords[counter][a] = ch[i]; // you do not need to try to concatenate, you are already walking down the buffer with 'a'
            a++;
        }

    }

    for (int i = 0; i < counter; i++) { // use 'counter' as it has the number of lines
       // since you 0 terminated the string you do not need to walk character by character

         cout << strWords[i] << "  ";

    }


    return 0;
}

You are also not detecting and terminating the last word (since there is no space after it). I will leave that to you. The code I show does not print the word 'line.'

You should really have tests to make sure you do not overflow the length or number of words.

Plus you should ideally use std::string and std::vector

Note - if, for experimentation, you do want to walk through char by char to output the strings you should look for the terminating '0' character and exit the inner loop

填充2D字符阵列并访问每个元素

玩套路吗 2025-02-04 16:34:54

尝试在项目的根目录中删除供应商文件夹,然后重新运行Go Mod Tidy(其中包含您的go.mod) 。

如果您仍然需要供应商,则每次要更新/更改依赖项时,都必须重新运行go mod

请查看 spec 涉及供应更多信息。

Try deleting the vendor folder and re-running go mod tidy in the root directory of your project (the one which contains your go.mod).

If you still need vendoring you have to re-run go mod vendor every time you want to update/change your dependencies.

Please have a look at the spec about vendoring for further information.

使用大猩猩/mux时错误,“供应商/quot”在导入的GitHub路径

玩套路吗 2025-02-04 10:18:15

我只在节目中添加了功能,并在此处隐藏是代码,以便您可以获得想法道具并相应地管理状态,所有剩余的代码都可以随意添加更多功能和CUSTOME状态

    import "./styles.css";
    import Modalbox from "./Modalbox";
    import { useState } from "react";
    export default function App() {
    const[handleShow,sethandleShow] = useState(false)
  return (
<div className="App">
  <button variant="primary" onClick={()=>sethandleShow(!handleShow)}>
    Launch demo modal
  </button>
 <Modalbox handleShow={handleShow} sethandleShow={sethandleShow} />
</div>
 );
}

MODALBOX.JS。

   import React, { useState } from "react";
  import { Modal, Button } from "react-bootstrap";

  function Modalbox(props) {
  const [modalshow, setShow] = useState(false);
  const handleClose = () => setShow(false);
  const handleShow = () => setShow(true);

   return (
<div>
  {/* <Modal show={modalshow} onHide={handleClose}> */}
  <Modal show={props.handleShow} onHide={()=>props.sethandleShow(!props.handleShow)}>
    <Modal.Header closeButton>
      <Modal.Title>Modal heading</Modal.Title>
    </Modal.Header>
    <Modal.Body>Woohoo, you're reading this text in a modal!</Modal.Body>
    <Modal.Footer>
      <Button variant="secondary" onClick={()=>props.sethandleShow(!props.handleShow)}>
        Close
      </Button>
      <Button variant="primary" onClick={handleClose}>
        Save Changes
      </Button>
    </Modal.Footer>
  </Modal>
</div>
  );
 }

 export default Modalbox;

I have added only functionality on the show and hide here is code so that you may get the idea props and manage the state accordingly all remaining code it feels free to add more functionality and custome state

    import "./styles.css";
    import Modalbox from "./Modalbox";
    import { useState } from "react";
    export default function App() {
    const[handleShow,sethandleShow] = useState(false)
  return (
<div className="App">
  <button variant="primary" onClick={()=>sethandleShow(!handleShow)}>
    Launch demo modal
  </button>
 <Modalbox handleShow={handleShow} sethandleShow={sethandleShow} />
</div>
 );
}

modalbox.js

   import React, { useState } from "react";
  import { Modal, Button } from "react-bootstrap";

  function Modalbox(props) {
  const [modalshow, setShow] = useState(false);
  const handleClose = () => setShow(false);
  const handleShow = () => setShow(true);

   return (
<div>
  {/* <Modal show={modalshow} onHide={handleClose}> */}
  <Modal show={props.handleShow} onHide={()=>props.sethandleShow(!props.handleShow)}>
    <Modal.Header closeButton>
      <Modal.Title>Modal heading</Modal.Title>
    </Modal.Header>
    <Modal.Body>Woohoo, you're reading this text in a modal!</Modal.Body>
    <Modal.Footer>
      <Button variant="secondary" onClick={()=>props.sethandleShow(!props.handleShow)}>
        Close
      </Button>
      <Button variant="primary" onClick={handleClose}>
        Save Changes
      </Button>
    </Modal.Footer>
  </Modal>
</div>
  );
 }

 export default Modalbox;

如何在React中调用单个模态框组件?

玩套路吗 2025-02-04 00:07:01

我可以一种建议,但不确定这是最好的方法。
步骤1:获取字段详细信息,这将返回structfield []
步骤2:通过接收的数组迭代并

private boolean isValidColumnTypes(String[] columnArray, Dataset<?> dataset) {
        StructField[] fieldArray = dataset.schema().fields();
        for (int i = 0; i < columnArray.length; i++) {
            for (StructField data : fieldArray) {
                    boolean doubleType=data.dataType().toString().equals("DoubleType");
                    boolean floatType=data.dataType().toString().equals("FloatType");   
                    if (columnArray[i].equals(data.name()) && !(doubleType ||floatType)){
                    return false;
                }
            }
        }
        return true;
    }

在上述方法中检查列的数据类型。

I can suggest one way but not sure that it's a best approach or not.
Step-1: get field details this will return StructField[]
Step-2: Iterate through received array and check data type of columns

private boolean isValidColumnTypes(String[] columnArray, Dataset<?> dataset) {
        StructField[] fieldArray = dataset.schema().fields();
        for (int i = 0; i < columnArray.length; i++) {
            for (StructField data : fieldArray) {
                    boolean doubleType=data.dataType().toString().equals("DoubleType");
                    boolean floatType=data.dataType().toString().equals("FloatType");   
                    if (columnArray[i].equals(data.name()) && !(doubleType ||floatType)){
                    return false;
                }
            }
        }
        return true;
    }

In the above method I am passing column names as String array String[] columnArray

如何在Spark中检查列数据类型

玩套路吗 2025-02-03 20:57:01

您可以这样做,child元素将填充所有空间,因此它们将是TAP目标,:: pseudo-element将是黄色圆圈:

const childs = [...document.querySelectorAll('.child')];
childs.map((x, i) => x.addEventListener('click', () => alert(`Hey child ${i}`)));
document.querySelector('.parent').style.setProperty('--childs', childs.length);
* { box-sizing: border-box, padding: 0, margin: 0 }

body {
 background-color: blue;
 padding: 0;
 margin: 0;
}
.parent {
  display: flex; 
  background-color: crimson; 
  height: 100px;
  flex-direction: row;
  justify-content: space-between; 
  align-items: center;
  overflow: hidden;
}
.child {
  --diameter: 36px;
  --slices: calc(var(--childs) * 2);
  --margin: calc(var(--diameter) / 2 + 16px);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  --width: calc(100% + 2 * calc(100% / var(--slices) - var(--margin)));
  --cut: calc(-1 * var(--width) / var(--slices) + var(--margin));
}
.child:first-child {
  margin-left: var(--cut);
}
.child:last-child {
  margin-right: var(--cut);
}
.child::before {
  content: '';
  position: absolute;
  background-color: gold;
  border-radius: 50%;
  width: var(--diameter);
  aspect-ratio: 1;
}

.ml, .mr {
  position: fixed;
  height: 100px;
  width: 1px;
  top: 0;
  background: black;
}
.ml {
  left: 16px;
}
.mr {
  right: 16px;
}
<div class="parent">
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
</div>

<div class="ml"></div>
<div class="mr"></div>

You can do it like this, the child elements will fill all the space so they will be the tap targets, the ::before pseudo-element will be the yellow circles:

const childs = [...document.querySelectorAll('.child')];
childs.map((x, i) => x.addEventListener('click', () => alert(`Hey child ${i}`)));
document.querySelector('.parent').style.setProperty('--childs', childs.length);
* { box-sizing: border-box, padding: 0, margin: 0 }

body {
 background-color: blue;
 padding: 0;
 margin: 0;
}
.parent {
  display: flex; 
  background-color: crimson; 
  height: 100px;
  flex-direction: row;
  justify-content: space-between; 
  align-items: center;
  overflow: hidden;
}
.child {
  --diameter: 36px;
  --slices: calc(var(--childs) * 2);
  --margin: calc(var(--diameter) / 2 + 16px);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  --width: calc(100% + 2 * calc(100% / var(--slices) - var(--margin)));
  --cut: calc(-1 * var(--width) / var(--slices) + var(--margin));
}
.child:first-child {
  margin-left: var(--cut);
}
.child:last-child {
  margin-right: var(--cut);
}
.child::before {
  content: '';
  position: absolute;
  background-color: gold;
  border-radius: 50%;
  width: var(--diameter);
  aspect-ratio: 1;
}

.ml, .mr {
  position: fixed;
  height: 100px;
  width: 1px;
  top: 0;
  background: black;
}
.ml {
  left: 16px;
}
.mr {
  right: 16px;
}
<div class="parent">
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
</div>

<div class="ml"></div>
<div class="mr"></div>

如何实现TAP目标以用Flexbox合理的空间空间填充空间?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文