Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anchor Tag doesnt take width of text on safari

enter image description here

For a while, I am trying to implement this where an anchor tag is inside a flex box container having flex-wrap: nowrap and overflow:auto now this works in google chrome but it doesn't work in safari for smaller screen sizes as well as Iphone. Following is the code

<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>

like image 403
Priyank Bhatt Avatar asked Oct 30 '22 23:10

Priyank Bhatt


1 Answers

Try this.. Also I've removed unused 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>
like image 70
Rahul K Avatar answered Nov 08 '22 08:11

Rahul K