【问题标题】:Search Box Placeholder aligning to left in my way搜索框占位符以我的方式向左对齐
【发布时间】:2019-06-12 16:01:36
【问题描述】:

目前我的代码工作正常,也与left 对齐,但我对当前的对齐方式不满意。

.text-box-container {
  overflow: hidden;
}

.text-box-container>input[type="search"] {
  width: 100% !important;
  text-align: left !important;
}
<div class="text-box-container">
  <input type="search">
</div>

我想把这段文字放在额外的左边。我的意思是,在某个位置。我将把它定义在某个位置的左侧。

我该怎么做?

【问题讨论】:

  • 您想缩进输入占位符还是输入文本?

标签: html css sass less


【解决方案1】:

你可以试试.abc元素:

.abc::placeholder {
   width: 100% !important;
   text-align: left !important;
   float:left;
   left:0;
}

【讨论】:

  • 我也应该在 HTML 类中分配这个 abc 吗?
  • 当然,您应该为 HTML 类分配这个,并为干净的代码指定一个确切的名称。祝你好运:D
【解决方案2】:

您可以使用text-indent 属性。

input::placeholder {
  text-indent: -15px;
}
&lt;input type="text" placeholder="enter text"/&gt;

【讨论】:

    猜你喜欢
    • 2021-10-14
    • 2015-01-28
    • 2014-07-23
    • 2017-03-24
    • 2012-07-08
    • 2016-09-24
    • 2013-12-21
    • 2014-03-02
    • 2011-07-29
    相关资源
    最近更新 更多