簡體   English   中英

如何設置類型=“按鈕”的輸入的樣式?

[英]How to style an input that is a type=“button”?

我正在嘗試使CSS更改成為一個彈出窗口,該彈出窗口基本上是一個帶有cookie策略的居中div,然后是一個“接受”按鈕。 我正在使用DNN CMS,並且彈出窗口是一個模塊,因此無法更改div或類名稱。

CSS可以很好地用於“接受”按鈕,但是會影響注釋表的輸入。 如何編寫CSS,以便CSS僅影響該div中的“接受”按鈕?

順便說一下,“接受”按鈕是type =“ button”的輸入。

“接受”按鈕的HTML

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

“接受”按鈕的CSS

#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

<input name="txtYourName" value="Anonymous" id="txtYourName" class="NormalTextBox" style="width: 100%" type="text">
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;
}

我假設您只想使用type = button定位第一個“接受”按鈕

#View_CookieConsent_sal_CloseLink {
....
}

應該管用

當您執行#View_CookieConsent_sal_CloseLink按鈕時,您的目標是該ID內的按鈕。 您還可以按屬性定位標簽

input[type=button] { ....  }

該ID在您的頁面中必須是唯一的。 我看到您生成了一個id="txtYourName" 用那個

#txtYourName{
   ...
}

輸入而不是#View_CookieConsent_sal_CloseLink按鈕,

使用此#txt您的姓名,#View_CookieConsent_sal_CloseLink

因此,CSS會觸發ID為txtYourName的按鈕和ID為View_CookieConsent_sal_CloseLink的cookie

祝好運

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM