我对占位符有问题,不管我做什么,它总是大写的。我试图添加我能找到的所有应该有帮助的css样式,但到目前为止还没有运气。有人能告诉我为什么会这样吗?
我的搜索栏的css
#navigation-bar {
height: 100%;
width: 500px;
float: right;
}
#search {
position: absolute;
top: 0;
right: 0;
width: 60px;
height: 100%;
}
#label {
width: 60px;
height: 100%;
position: relative;
z-index: 20;
}
#label label {
display: block;
width: 60px;
height: 100%;
background: url("../../images/search.png") no-repeat center center;
font-size: 0;
color: rgba(0, 0, 0, 0);
text-indent: -9999px;
cursor: pointer;
}
#label label:hover {
background: url("../../images/search.png") no-repeat center center;
}
#label.active label {
background: url("../../images/search.png") no-repeat center center;
}
#input {
position: absolute;
top: 0;
right: 60px;
width: 450px;
height: 100%;
z-index: 5;
overflow: hidden;
}
#input input {
display: block;
position: absolute;
top: 0;
right: -450px;
width: 450px;
height: 100%;
margin: 0;
padding: 0 10px;
border: none;
background-color: #333;
color: #fff;
font-size: 18px;
backface-visibility: none;
border-radius: 0;
transition: left 0;
}
#input input:focus {
outline: none;
}
#input.focus {
z-index: 20;
}
#input.focus input {
right: 0;
transition: right 0.3s;
}
::-webkit-input-placeholder {
text-transform: none;
}
:-moz-placeholder {
text-transform: none;
}
::-moz-placeholder {
text-transform: none;
}
:-ms-input-placeholder {
text-transform: none;
}
HTML
<div class="content-container">
<div class="top-wrapper">
<div class="top">
<div class="navigation">
<div class="container">
<div class="navbar-collapse collapse">
<div id="navigation-bar" class="clearfix">
<form id="search" onkeypress="return event.keyCode != 13;" action="@Model.SearchPageUrl" method="post">
<div id="input"><input type="text" name="search-terms" id="search-terms" placeholder="@Model.SearchPlaceholder"></div>
<div id="label"><label for="search-terms" id="search-label">search</label></div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
答案 0 :(得分:1)
I dont think you can just do ::-webkit-input-placeholder
try with specificying the input first like so:
input::-webkit-input-placeholder {
text-transform: lowercase;
}
答案 1 :(得分:0)
我不仅会做@Brad所说的话,而且还会为你的风格添加!important
。这有望确保没有其他样式接管您的输入元素。不幸的是,你无法检查&#34;占位符属性(至少我还没能)
input::-webkit-input-placeholder {
text-transform: none !important;
}
input:-moz-placeholder {
text-transform: none !important;
}
input::-moz-placeholder {
text-transform: none !important;
}
input:-ms-input-placeholder {
text-transform: none !important;
}
我也建议改为使用inherit
:
input::-webkit-input-placeholder {
text-transform: inherit !important;
}
input:-moz-placeholder {
text-transform: inherit !important;
}
input::-moz-placeholder {
text-transform: inherit !important;
}
input:-ms-input-placeholder {
text-transform: inherit !important;
}
答案 2 :(得分:0)
::-webkit-input-placeholder {
text-transform: none;
}
:-moz-placeholder {
text-transform: none;
}
::-moz-placeholder {
text-transform: none;
}
:-ms-input-placeholder {
text-transform: none;
}
你写的这段代码,做你想要的,它应该工作。我认为你应该检查它是否被其他更精确的CSS选择器覆盖。尝试添加更精确的选择器来检查它,例如:
body input#search-terms::-webkit-input-placeholder {
text-transform: none;
}
body input#search-terms:-moz-placeholder {
text-transform: none;
}
body input#search-terms::-moz-placeholder {
text-transform: none;
}
body input#search-terms:-ms-input-placeholder {
text-transform: none;
}