@media 上的文本输入没有改变

text input doesn`t change on @media

我尝试使用这个 UI 输入,但是当我使用媒体查询时它没有任何改变。

当我尝试另一个 UI 时它有效,但不适用于这个。

................................................ ..................................................... ..................................................... ............

我的代码有什么问题?

.centered 
{
  width: 50%;
  margin: auto;
}

.group {
  width: 100%;
  overflow: hidden;
  position: relative;
} 

.label {
  position: absolute;
  top: 40px;
  color: #666666;
  font: 400 26px Roboto;
  cursor: text;
  transition: 0.3s ease;
  width: 100%;
  text-align: center;
}

.input {
  display: block;
  width: 100%;
  padding-top: 36px;
  border: none;
  border-radius: 0;
  font-size: 30px;
  transition: .3s ease;
  text-align: center;
}
.input:valid ~ .label {
  top: 3px;
  font: 400 26px Roboto;
}
.input:focus {
  outline: none;
}
.input:focus ~ .label {
  top: 3px;
  font: 400 26px Roboto;
}
.input:focus ~ .bar:before {
  transform: translateX(0);
}
.bar {
  border-bottom: 2px solid #ff5126;
  width: 100%;
  margin-top: 6px;
  transition: .3s ease;
}
.input:valid ~ .bar
{
  border-bottom: 2px solid #3bb873;
}
@media screen and (max-width: 1000px)
{
 #centered-email
 {
  width: 100%;
 }
 
}
        <div class="centered">
         <div class="group">
          <input type="text" class="input name" id="name" required autocomplete="off"/>
          <label class="label name-l" for="name">ایمیل</label>
          <div class="bar"></div>
         </div>
        </div>

我猜这些是问题所在:

1) Can't find div with id named "#centered-email".

2) Use @media only screen instead of @media screen

在 jsfiddle 中查看:http://jsfiddle.net/3ob20zwx/3/

看起来正在工作。希望你得到了你正在寻找的东西 :) 美好的一天!

id -> centered-email 没有元素。

更改为完成-

在您的媒体查询中将 #centered-email 替换为 .centered,这将解决您当前的问题。

固定片段 -

.centered {
  width: 50%;
  margin: auto;
}

.group {
  width: 100%;
  overflow: hidden;
  position: relative;
}

.label {
  position: absolute;
  top: 40px;
  color: #666666;
  font: 400 26px Roboto;
  cursor: text;
  transition: 0.3s ease;
  width: 100%;
  text-align: center;
}

.input {
  display: block;
  width: 100%;
  padding-top: 36px;
  border: none;
  border-radius: 0;
  font-size: 30px;
  transition: .3s ease;
  text-align: center;
}

.input:valid~.label {
  top: 3px;
  font: 400 26px Roboto;
}

.input:focus {
  outline: none;
}

.input:focus~.label {
  top: 3px;
  font: 400 26px Roboto;
}

.input:focus~.bar:before {
  transform: translateX(0);
}

.bar {
  border-bottom: 2px solid #ff5126;
  width: 100%;
  margin-top: 6px;
  transition: .3s ease;
}

.input:valid~.bar {
  border-bottom: 2px solid #3bb873;
}

@media screen and (max-width: 1000px) {
  .centered {
    width: 100%;
  }
}
<div class="centered">
  <div class="group">
    <input type="text" class="input name" id="name" required autocomplete="off" />
    <label class="label name-l" for="name">ایمیل</label>
    <div class="bar"></div>
  </div>
</div>