锚标记不会在safari

时间:2016-07-16 19:44:34

标签: css flexbox anchor

enter image description here

有一段时间,我正在尝试实现这一点,其中锚标记位于具有flex-wrap: nowrapoverflow:auto的弹性框容器内,现在这在谷歌浏览器中有效,但它在safari中不起作用更小的屏幕尺寸以及Iphone。以下是代码

<html>
<head>
</head>
    <style>
        .flex-div {
            display: -webkit-box;
            display: -webkit-flex;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-orient: horizontal;
            -webkit-box-direction: normal;
            -webkit-flex-direction: row;
            -ms-flex-direction: row;
            flex-direction: row;
            -webkit-flex-wrap: nowrap;
            -ms-flex-wrap: nowrap;
            flex-wrap: nowrap;
            overflow-x: auto;
        }
        .flex-div a {
            display: inline-block;
            white-space: nowrap;
            margin-left: 10px;
            margin-right: 10px;
        }
    </style>
<body>
    <div class="flex-div">
        <a>Modern & contemporary</a>
        <a>Modern & contemporary</a>
        <a>Modern & contemporary</a>
        <a>Modern & contemporary</a>
        <a>Modern & contemporary</a>
        <a>Modern & contemporary</a>
        <a>Modern & contemporary</a>
        <a>Modern & contemporary</a>
        <a>Modern & contemporary</a>
        <a>Modern & contemporary</a>
        <a>Modern & contemporary</a>
        <a>Modern & contemporary</a>

    </div>
</body>

1 个答案:

答案 0 :(得分:2)

试试这个..我也删除了未使用的CSS。

.flex-div {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  overflow-x: auto;
}
.flex-div a {
  white-space: nowrap;
  margin-left: 10px;
  margin-right: 10px;
  -ms-flex: none;
  -webkit-flex: none;
  flex: none;
}
<div class="flex-div">
  <a>Modern & contemporary</a>
  <a>Modern & contemporary</a>
  <a>Modern & contemporary</a>
  <a>Modern & contemporary</a>
  <a>Modern & contemporary</a>
  <a>Modern & contemporary</a>
  <a>Modern & contemporary</a>
  <a>Modern & contemporary</a>
  <a>Modern & contemporary</a>
  <a>Modern & contemporary</a>
  <a>Modern & contemporary</a>
  <a>Modern & contemporary</a>
</div>