【问题标题】:Search Field Text doesn't display in FF 3.6?FF 3.6 中不显示搜索字段文本?
【发布时间】:2012-04-04 09:17:40
【问题描述】:

搜索表单几乎是默认的 21 个 Wordpress 表单的样式化版本。

默认文本显示几乎无处不在——但不是在 FF 3.6 中,可能是较旧的 IE。我假设因为默认情况下 21 个主题在搜索中使用了一些 CSS3 调用。无论如何——又是什么传统代码适用于表单字段默认文本??

(我宁愿不使用 PHP、jQuery、JS) -- 但最终哪条路线是可靠的。

这是搜索表单中的代码:

<?php
/**
 * The template for displaying search forms in Twenty Eleven
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */
?>
    <form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
        <label for="s" class="assistive-text"><?php _e( 'Search', 'twentyeleven' ); ?></label>
        <input type="text" class="field" name="s" id="s" placeholder="<?php esc_attr_e( 'Search, title, author, keyword', 'twentyeleven', 'twentyeleven' ); ?>" />
        <input type="submit" class="submit" name="submit"  id="searchsubmit" value="<?php esc_attr_e( 'Search' ); ?>" />
    </form>

<div id="searchtbtn"><img src="http://mysite.com/wp-content/uploads/2012/03/searchnav_btn.gif" style="margin-left: 292px; margin-top: 60px; max-height: 35px; max-width: 70px; position: absolute;"></div>

【问题讨论】:

    标签: javascript html css forms wordpress


    【解决方案1】:

    占位符属性&lt;input type="text" placeholder="... 是 HTML5 的一部分,如果您想要一个非 PHP、非 jQuery、非 JavaScript 后备,那么您可以设置默认值或使用 CSS 设置样式背景图像。

    【讨论】:

    • 感谢您的回复。如何设置“默认”值?
    • 您可以为输入字段指定一个 value="something"(例如 &lt;input type="text" value="Search" ...。但是由于您不想使用 JavaScript,因此用户需要在输入他们的内容之前删除此文本搜索词。IMO 使用 jQuery 来处理这将是最好的解决方案。
    猜你喜欢
    • 2018-10-14
    • 2015-06-13
    • 1970-01-01
    • 2022-09-29
    • 1970-01-01
    • 1970-01-01
    • 2014-10-26
    • 1970-01-01
    相关资源
    最近更新 更多