文書更新:2017年09月13日(水) 午後2時07分00秒

Home > その他 > サイト内検索 > google 検索のコード( 168 )

「Googleカスタム検索」からコードを取得

  1. Google カスタム検索」から、必要事項を入力し、最後の「3.コードの取得」で「次のステップ」の「デザインを変更する」でコードを取得する。
  2. 下記のようにコードを変更した。
  3. 「style sheet」は必要のないものも掲載して有ります。

script

<div id="cse" style="width: 100%;">Loading</div>
<script src="http://www.google.co.jp/jsapi" type="text/javascript"></script>
<script type="text/javascript"> 
  google.load('search', '1', {language : 'ja', style : google.loader.themes.BUBBLEGUM});←緑の部分は「GREENSKY,MINIMALIST,BUBBLEGUM,ESPRESSO,SHINY」の中から選ぶことができる。
  google.setOnLoadCallback(function() {
    var customSearchOptions = {};  var customSearchControl = new google.search.CustomSearchControl(
      '011388300500121687820:fdx-tpwv7ds', customSearchOptions);
    customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
    customSearchControl.draw('cse');
  }, true);
</script>

style sheet

<style type="text/css">
.gsc-control-cse {/*全体*/
	font-family: "Trebuchet MS", sans-serif;
	background: none;	←背景を透明にした
	border: none;	←境界線をひかない
}
.gsc-control-cse .gsc-table-result {
	font-family: "Trebuchet MS", sans-serif;
}
input.gsc-input {/*検索窓*/
	border-color: #cccccc;
}
input.gsc-search-button {/*検索ボタン*/
	background-color: #B0E0E6;
	border-top: solid 1px #ffffff;
	border-right: solid 1px #897858;
	border-bottom: solid 1px #897858;
	border-left: solid 1px #ffffff;
}
.gsc-tabHeader.gsc-tabhInactive {
	border-color: #A9DA92;
	background-color: #FFFFFF;
}
.gsc-tabHeader.gsc-tabhActive {
	border-color: #A9DA92;
	background-color: #B5C9AB;
}
.gsc-tabsArea {
	border-color: #A9DA92;
}
.gsc-webResult.gsc-result,
.gsc-results .gsc-imageResult {
	border-color: #A9DA92;
	background-color:none;/*#FFFFFF;*/	/*変更した*/
}
.gsc-webResult.gsc-result:hover,
.gsc-webResult.gsc-result.gsc-promotion:hover,
.gsc-imageResult:hover {
	border-color: #009090;	/*変更した*/
	background-color: #FFFFFF;
}
.gs-webResult.gs-result a.gs-title:link,
.gs-webResult.gs-result a.gs-title:link b,
.gs-imageResult a.gs-title:link,
.gs-imageResult a.gs-title:link b {
	color: #0066CC;
}
.gs-webResult.gs-result a.gs-title:visited,
.gs-webResult.gs-result a.gs-title:visited b,
.gs-imageResult a.gs-title:visited,
.gs-imageResult a.gs-title:visited b {
	color: #0066CC;
}
.gs-webResult.gs-result a.gs-title:hover,
.gs-webResult.gs-result a.gs-title:hover b,
.gs-imageResult a.gs-title:hover,
.gs-imageResult a.gs-title:hover b {
	color: #0066CC;
}
.gs-webResult.gs-result a.gs-title:active,
.gs-webResult.gs-result a.gs-title:active b,
.gs-imageResult a.gs-title:active,
.gs-imageResult a.gs-title:active b {
	color: #0066CC;
}
.gsc-cursor-page {
	color: #0066CC;
}
a.gsc-trailing-more-results:link {
	color: #0066CC;
}
.gs-webResult .gs-snippet,
.gs-imageResult .gs-snippet,
.gs-fileFormatType {
color: #454545;
}
.gs-webResult div.gs-visibleUrl,
.gs-imageResult div.gs-visibleUrl {
	color: #815FA7;
}
.gs-webResult div.gs-visibleUrl-short {
	color: #815FA7;
}
.gs-webResult div.gs-visibleUrl-short {
	display: none;
}
.gs-webResult div.gs-visibleUrl-long {
	display: block;
}
.gs-promotion div.gs-visibleUrl-short {
	display: none;
}
.gs-promotion div.gs-visibleUrl-long {
	display: block;
}
.gsc-cursor-box {
	border-color: #A9DA92;
}
.gsc-results .gsc-cursor-box .gsc-cursor-page {/*下のページ番号*/
	text-decoration: none;/*追加した*/
	border-color: #cccccc;
	background-color: none;
}
.gsc-results .gsc-cursor-box .gsc-cursor-current-page {/*下のページ番号*/
	background-color: #B0E0E6;
	border-top: solid 1px #ffffff;
	border-right: solid 1px #897858;
	border-bottom: solid 1px #897858;
	border-left: solid 1px #ffffff;
}
.gsc-webResult.gsc-result.gsc-promotion {
	border-color: #94CC7A;
	background-color: #CBE8B4;
}
.gsc-completion-title {
	color: #0066CC;
}
.gsc-completion-snippet {
	color: #454545;
}
.gs-promotion a.gs-title:link,
.gs-promotion a.gs-title:link *,
.gs-promotion .gs-snippet a:link {
	color: #0066CC;
}
.gs-promotion a.gs-title:visited,
.gs-promotion a.gs-title:visited *,
.gs-promotion .gs-snippet a:visited {
	color: #0066CC;
}
.gs-promotion a.gs-title:hover,
.gs-promotion a.gs-title:hover *,
.gs-promotion .gs-snippet a:hover {
	color: #0066CC;
}
.gs-promotion a.gs-title:active,
.gs-promotion a.gs-title:active *,
.gs-promotion .gs-snippet a:active {
	color: #0066CC;
}
.gs-promotion .gs-snippet,
.gs-promotion .gs-title .gs-promotion-title-right,
.gs-promotion .gs-title .gs-promotion-title-right *  {
	color: #454545;
}
.gs-promotion .gs-visibleUrl,
.gs-promotion .gs-visibleUrl-short {
	color: #815FA7;
}
</style>