正如标题所示,以下代码的输出在safari浏览器上没有显示:
1)输入类型搜索的边框未显示
2)text-transform:大写不起作用.
其余的浏览器显示确切的输出.请参阅下面附带的图像.
HTML:
<div class="searchLob">
<input type="search" class="searchInput" placeholder="Search the website"></input>
<button onclick="Submit();" class="searchInputBtn">Search</button>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.searchLob{
position: relative;
display: inline-block;
}
.searchInput{
position: relative;
border: 2px solid #d2d4d8;
height: 44px;
padding: 0 10px;
background-color: #fff;
width: 200px;
margin: 2px 0 0 2px;
float: left;
text-transform: uppercase;
}
.searchInputBtn{
position: relative;
float: left;
border: medium none;
color: #fff;
cursor: pointer;
font: 14px 'arial';
height: 44px;
margin-left: -4px;
margin-top: 2px;
text-decoration: none;
text-transform: uppercase;
width: 70px;
background-color: #6692a7;
}
.searchInputBtn:hover{
background-color:#547e92;
}
textarea:focus, input:focus, select:focus{
border-color: #cccfd0;
box-shadow: 0 1px 1px rgba(204, 207, 208, 0.075) inset, 0 0 8px rgba(204, 207, 208, 1);
outline: 0 none;
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过以下方法:
CSS:
@media screen and (-webkit-min-device-pixel-ratio:0) {
/* Safari and Chrome */
.myClass {
color:red;
}
/* Safari only override */
::i-block-chrome,.myClass {
color:blue;
}
}
Run Code Online (Sandbox Code Playgroud)
使它适用于野生动物园,但没有做任何事情.
我该怎么办?
?
[我正在使用Safari浏览器版本:5.1.7(Build:7534.57.2)]
如果删除所有CSS,并检查Safari中的元素,您会发现有很多CSS被添加user agent stylesheet
- 这是浏览器的默认样式表,因浏览器而异.
例如,这是添加到输入的一些默认样式:
input[type="search"] {
-webkit-appearance: searchfield;
box-sizing: border-box;
}
user agent stylesheet
input, input[type="password"], input[type="search"], isindex {
-webkit-appearance: textfield;
padding: 1px;
background-color: white;
border: 2px inset;
-webkit-rtl-ordering: logical;
-webkit-user-select: text;
cursor: auto;
}
user agent stylesheet
:focus {
outline: 5px auto -webkit-focus-ring-color;
}
Run Code Online (Sandbox Code Playgroud)
正如博客文章中所述 - 在Webkit中重置HTML5搜索输入
重置Safari默认样式的方法是添加以下CSS:
/* Reset HTML5 Search Input in Webkit */
input[type=search]::-webkit-search-cancel-button,
input[type=search]::-webkit-search-decoration,
input[type=search]::-webkit-search-results-button,
input[type=search]::-webkit-search-results-decoration {
-webkit-appearance:none;
}
input[type=search] {
-webkit-appearance:textfield;
-webkit-box-sizing:content-box;
}
Run Code Online (Sandbox Code Playgroud)
所以如果你现在检查小提琴 - http://jsfiddle.net/Hg2A6/8/你会发现它得到了正确的造型