锚标签不占用 safari 上的文本宽度
Anchor Tag doesnt take width of text on safari
有一段时间,我试图实现这个,其中锚标记位于具有 flex-wrap: nowrap
和 overflow:auto
的弹性框容器内,现在这在 google [=21= 中有效] 但它在 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>
试试这个。我还删除了未使用的 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>
有一段时间,我试图实现这个,其中锚标记位于具有 flex-wrap: nowrap
和 overflow:auto
的弹性框容器内,现在这在 google [=21= 中有效] 但它在 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>
试试这个。我还删除了未使用的 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>