Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safari Flex item unwanted 100% width CSS

I have an element with these properties

.Task-header {
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: row;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-flex-wrap: nowrap;
    -ms-flex-wrap: nowrap;
    flex-wrap: nowrap;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-align-content: flex-start;
    -ms-flex-line-pack: start;
    align-content: flex-start;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
}

In Chrome it's children behave as you would expect, i.e. space between each other: Chrome

In Safari 10.1.2, each child takes up the full width and as such they appear below each other Safari

What do I need to do to fix the Safari one?

Edit: Here's the JSX:

<details>
    <summary className="Task-header">
        <h3 className="Task-header-title">{data.Name + " [" + version + "]"}</h3>
        <span className={"mdi mdi-18px " + (data.Status.State === "running" ? "mdi-checkbox-marked-circle" : "mdi-close-circle")}/>
    </summary>
    <h3>{data.Name + " [" + version + "]"}</h3><span></span>
    <div className="Task-body">
        <p>CPU %: <b>{data.cpuUsage}</b></p>
        <p>Mem Usage/Limit: <b>{data.memoryUsage}/{data.memoryLimit}</b></p>
        <p>Mem %: <b>{data.memoryPercent}</b></p>
        <p>Block I/O: <b>{data.blockRead}/{data.blockWrite}</b></p>
        <p>Net I/O: <b>{data.netRead}/{data.netWrite}</b></p>
        <p>{dateString}</p>
    </div>
</details>

CSS on children:

.Task-header-title {
    font: 600 .875rem Averta;
    margin: 0;
}

MDI

like image 640
Roberto Graham Avatar asked Sep 14 '25 10:09

Roberto Graham


1 Answers

This is related to a FlexBug in Safari where some elements are unable to be flex parents (see https://github.com/philipwalton/flexbugs#9-some-html-elements-cant-be-flex-containers). Summary tags appear to be one of these elements.

You can work around the issue by nesting a div under your summary like so:

<summary >
  <div className="Task-header">
        <h3 className="Task-header-title">{data.Name + " [" + version + "]"}</h3>
        <span className={"mdi mdi-18px " + (data.Status.State === "running" ? "mdi-checkbox-marked-circle" : "mdi-close-circle")}/>
  </div>
</summary>
like image 129
kball Avatar answered Sep 17 '25 01:09

kball