我正在使用Drupal 6,致力於將靜態HTML和CSS文件轉換爲Drupal主題。到目前爲止,大部分進展順利。我如何主題搜索表單,但對於Drupal 6主題?轉換一個CSS樣式的搜索框在Drupal主題中使用?
我對此感到困惑的是,我是否將template.php
文件與 search-theme-form.tpl.php
文件一起使用?我可以在search-theme-form.tpl.php
文件中導入我的style.css
工作表嗎?或者我可以直接粘貼到我的CSS中?
我已將搜索框上傳到此處,以便您瞭解其行爲和外觀。 http://nside-elite.techiedesign.net/testsearchform/testsearchform.html
這是我原來的CSS:
#searchwrap {
width: 330px;
height: 51px;
margin-right: auto;
position: relative;
margin-left: auto;
top: 150px;
}
#searchboxwrapper {
height: 28px;
float: left;
width: 277px;
}
#searchbuttonwrapper {
width: 53px;
height: 28px;
float: right;
}
.preload {
position: absolute;
top: 0px;
left: 0px;
width: 1px;
height: 1px;
visibility: hidden;
overflow: hidden;
}
.searchbox {
background-position: top;
background-color: #515151;
background-image: url('Images/searchbox-shadow.png');
border: 2px #333333 solid;
outline: none;
background-repeat: repeat-x;
height: 20px;
margin-right: 3px;
float: right;
margin-top: 1px;
width: 250px;
text-indent: 5px;
font-size: 10pt;
color: #1D1D1D;
font-style: italic;
font-family: Arial;
}
.searchbutton {
background: url('Images/go-button.png');
background-repeat: no-repeat;
cursor: pointer;
width: 53px;
height: 28px;
border: 0px;
}
.searchbutton:hover {
background: url('Images/go-button-gifsmooth.gif');
background-repeat: no-repeat;
border: 0px;
}
.searchbutton:active {
background: url('Images/go-button-pressed.png');
background-repeat:no-repeat;
border: 0px;
}
.searchbox:focus {
border: 2px;
border-color: #6B6B6B;
border-style: solid;
}
和HTML:
<div id="searchboxwrapper">
<input name="Text1" type="text" class="searchbox" value="Search Nside Elite" onfocus="if(this.value == 'Search Nside Elite'){this.value = '';this.style.fontStyle='normal';this.style.color='#BFBFBF';}" onblur="if(this.value == '') {this.value='Search Nside Elite';this.style.fontStyle='italic';this.style.color='#222222'}" />
</div>
<div id="searchbuttonwrapper">
<input name="searchbutton" type="button" value="" title="Search" class="searchbutton" />
</div>
沒有人在Drupal的論壇會給我一天的時間。我會很感激你可以提供的任何幫助。我不熟悉PHP。
謝謝!
也可以通過在預處理函數中使用drupal_add_css()來添加css文件,或者簡單地在另一個更常規的css文件中使用這些樣式。編輯 - 語法 – Donnyboy 2011-03-14 08:38:00
非常感謝您的幫助。我設法通過使用CSS和template.php來覆蓋默認樣式,從而使我的文本框看起來和行爲符合我的要求。關於提交按鈕,我還有一個問題。我如何才能更改提交按鈕,並僅使用CSS爲搜索框設置樣式?當我說我的意思是不覆蓋網站上的所有提交按鈕時。再一次感謝你! – Matt 2011-03-17 03:45:34
我使用CSS和這段代碼在template.php中編寫了代碼,但是這覆蓋了我所不想要的所有按鈕。對不起,我必須將我的代碼放入Google,因爲它超出了評論字符限額。 – Matt 2011-03-17 05:02:12