【问题标题】:Google Custom Search display issue in Foundation 3Foundation 3 中的 Google 自定义搜索显示问题
【发布时间】:2012-12-27 02:35:27
【问题描述】:

我正在尝试添加 Google 自定义搜索,但它一直显示不正确。按钮上的搜索图标不见了,看起来好像文本框的底部被切断了。

新成员,所以我不能发布图片。

代码

<div id="header">
  <div class="row">
    <div class="four columns">
      <h1><img src="images/QEFLogo.JPG" /></h1>
    </div>
    <div class="four offset-by-two columns">
      <div id="iso" class="hide-for-small">
        <h1>
          <img src="images/ISO9001.jpg" />
          <img src="images/ISO14001.jpg" />
        </h1>
      </div>
      <div id="gcsearch" class="hide-for-small">
        <gcse:searchbox-only></gcse:searchbox-only>
      </div>
    </div>
  </div>
</div>

没有真正的 CSS 可言...

#gcsearch {
    width:300px;
    position:relative;
    left:-5px;
}

脚本与 Google 生成的代码无关。

EDIT 现在发现是这个问题。 Google 元素在其服务器上使用 CSS 文件 default.css。这会生成宽度和高度。

在它定义的 CSS 表的第 126 行...

.cse .gsc-search-button input.gsc-search-button-v2, 
input.gsc-search-button-v2 {
    height: 13px;
    margin-top: 2px;
    min-width: 13px;
    padding: 6px 27px;
    width: 13px;
}

请记住,我根本没有太多 Javascript 知识,为什么会发生这种情况,我该如何解决?

我在非 Foundation 页面上测试了代码,它可以正确呈现。

【问题讨论】:

标签: html css responsive-design zurb-foundation google-custom-search


【解决方案1】:

这是 Foundation 框架的问题。将以下内容添加到按钮并解决。引用的类是由 Google 生成的,这就是为什么它们没有显示在我上面的代码中。

input.gsc-search-button, input.gsc-search-button:hover, input.gsc-search-button:focus {
background-image: inherit;
box-sizing: content-box;
}

【讨论】:

  • 遇到了同样的问题,现在使用 Google 类的第 2 版,我添加了以下 css,请参阅下面的答案。
【解决方案2】:

我现在遇到了同样的问题。使用 Google 类的第 2 版,我添加了以下 css

<style>
 .cse .gsc-search-button input.gsc-search-button-v2, input.gsc-search-button-v2 {
   background-image: inherit;
   box-sizing: content-box;
   -moz-box-sizing: content-box;
 }
</style>

现在可以在 Chrome 和 Firefox 中使用

【讨论】:

    【解决方案3】:

    您的代码中有一个过多的&lt;/div&gt; 结束标记。这使它成为无效的 HTML,并且可能是它显示错误的原因。

    【讨论】:

    • 改变了,还是一样。我在一个空白页面上进行了测试,结果显示正确,所以我认为它与基础框架有关。
    • 您能否编辑您的问题,使代码反映您真正拥有的内容?目前,您有 6 个打开的 &lt;div&gt; 标签和 7 个关闭的 &lt;/div&gt;。如果我们看不到您的真实代码,我们将无法帮助您。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-17
    • 1970-01-01
    • 2020-05-16
    • 2012-06-30
    • 1970-01-01
    相关资源
    最近更新 更多