如何制作谷歌自定义搜索引擎的背景(透明)?

时间:2016-11-07 17:02:07

标签: javascript html css

默认情况下,背景显示为白色。是否可以通过任何方式将其背景颜色更改为透明..?

<script>
  (function() {
    var cx = '005519348941191855053:d0uziw7c2dq';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
  })();
</script>
<gcse:search></gcse:search>

Image of Google CSE(white background)

1 个答案:

答案 0 :(得分:1)

如果你想让容器透明。您可以随时检查Google脚本的输出,并通过CSS添加自定义。您可以使用.gsc-control-cse

定位!important

&#13;
&#13;
body {
  background:#f44336;
}
.gsc-control-cse {
  background:transparent !important; /* enforce this rule; do not allow override */
  border-color:transparent !important; /* border color */
}
&#13;
<script>
  (function() {
    var cx = '005519348941191855053:d0uziw7c2dq';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
  })();
</script>
<gcse:search></gcse:search>
&#13;
&#13;
&#13;