如何设置类型="按钮的输入"?

时间:2014-03-12 14:04:06

标签: html css button input

我正在尝试让CSS更改一个弹出窗口,它基本上是一个带有Cookie政策的居中div,然后是“接受”'按钮。我正在使用DNN CMS,弹出窗口是一个模块,因此无法更改div或类名称。

CSS适用于'接受'按钮,但它会影响Comment表的输入。如何编写CSS以便CSS仅影响'接受'那个div中的按钮?

顺便说一句,接受'按钮是一个输入类型="按钮"。

HTML for' Accept'按钮

<input name="CookieConsent_CloseLink" id="View_CookieConsent_sal_CloseLink" value="Accept" type="button">

CSS&#39;接受&#39;按钮

#View_CookieConsent_sal_CloseLink button, input {
font-family: 'Oswald', arial, sans-serif;
text-transform: uppercase;
font-size: 14px;
padding: 5px;
position: absolute;
left: 40%;
margin-top: 10px;
margin-bottom: 10px;
}

HTML for&#39; Accept&#39;按钮

<input name="txtYourName" value="Anonymous" id="txtYourName" class="NormalTextBox" style="width: 100%" type="text">

4 个答案:

答案 0 :(得分:4)

input[type="button"] {
  font-family: 'Oswald', arial, sans-serif;
  text-transform: uppercase;
  font-size: 14px;
  padding: 5px;
  position: absolute;
  left: 40%;
  margin-top: 10px;
  margin-bottom: 10px;
}

答案 1 :(得分:0)

我假设您只想使用type = button

定位第一个Accept按钮
#View_CookieConsent_sal_CloseLink {
....
}

应该有效

当您执行#View_CookieConsent_sal_CloseLink按钮时,您将定位该ID内的按钮。您还可以按属性

定位标记
input[type=button] { ....  }

答案 2 :(得分:0)

The id would have to be unique in your page.我看到您生成了id="txtYourName"。使用它。

#txtYourName{
   ...
}

答案 3 :(得分:0)

而不是#View_CookieConsent_sal_CloseLink按钮,输入

使用此#txtYourName,#View_CookieConsent_sal_CloseLink

因此CSS将触发id为txtYourName的按钮 和id为View_CookieConsent_sal_CloseLink

的cookie

祝你好运