我想让我的中的占位符文本居中。下面的代码在Chrome和IE中运行良好,但在Safari中左对齐:
::-webkit-input-placeholder {
text-align:center;
}
:-moz-placeholder {
text-align:center;
}
如何在Safari中使其居中(最好只使用CSS)?
我想让我的中的占位符文本居中。下面的代码在Chrome和IE中运行良好,但在Safari中左对齐:
::-webkit-input-placeholder {
text-align:center;
}
:-moz-placeholder {
text-align:center;
}
如何在Safari中使其居中(最好只使用CSS)?
<input type="text" placeholder="Lorem ipsum" />
CSS
input { width: 200px; }
::-webkit-input-placeholder {
text-align:center;
}
:-moz-placeholder {
text-align:center;
}
:-ms-input-placeholder {
text-align:center;
}
Safari 5.1 + Win7
这个组合也不支持 text-align
。我还没有在这个组合上测试过。 - Wallace Sidhréetextarea {
min-height: 60px;
}
textarea::-webkit-input-placeholder, {
text-align: center;
line-height: 60px; // Input Height
}
textarea:-moz-placeholder { /* Firefox 18- */
text-align: center;
line-height: 60px; // Input Height
}
textarea::-moz-placeholder { /* Firefox 19+ */
text-align: center;
line-height: 60px; // Input Height
}
textarea:-ms-input-placeholder {
text-align: center;
line-height: 60px; // Input Height
}
input{
height:40px;
width:190px;
text-indent:60px;
}
input[type=textarea]
{
line-height: 1;
}
我做了一个简单的解决方案,适用于Safari 5+和所有其他浏览器,您可以在此处查看:http://jsfiddle.net/joaorito/RqUJL
HTML
<div class="center_area">
<ul class="V_align">
<li class="V_cell">
<div class="V_element">Maecenas sed diam eget risus varius blandit sit amet non magna.</div>
</li>
</ul></div>
CSS
.center_area
{
font-size: 16px;
width: 300px;
height: 300px;
border: 5px solid black;
}
.center_area ul
{
margin: 0;
padding: 0;
list-style: none;
background-color: red;
height: 100%;
width: 100%;
}
.center_area ul li
{
color: #FFF;
font-size: 1.500em;
line-height: 28px;
}
.center_area ul li div
{
background-color: green;
padding: 10px;
text-align: center;
}
.center_area .V_align
{
display: table;
overflow: hidden;
}
.center_area .V_align .V_cell
{
display: table-cell;
vertical-align: middle;
width: 100%;
margin: 0 auto;
}
.center_area .V_align .V_cell .V_element
{
display: block;
}