搜索框不工作

发布于 2024-11-26 18:26:15 字数 3275 浏览 2 评论 0原文

我想实现主菜单位于左侧而搜索框位于右侧的栏。我的代码是:

  <div id="divMenu">
    <div id="menu">
      <ul>
        <li><a href="index.html" class="active"><span>Home</span></a></li>
        <li><a href="#"><span>About Us</span></a></li>
        <li><a href="#"><span>Events/Services</span></a>
          <ul>
            <li><a href="#"><span>submenu1</span></a></li>
            <li><a href="#"><span>submenu2</span></a></li>
            <li><a href="#"><span>submenu3</span></a></li>
          </ul>
        </li>
        <li><a href="#"><span>Ventures</span></a></li>
        <li><a href="#"><span>Testimonials</span></a></li>
        <li><a href="#"><span>Resources</span></a></li>
        <li><a href="#"><span>e-Commerce</span></a></li>
        <li><a href="#"><span>Contact Us</span></a></li>
      </ul>
    </div>
    <div id="search">
      <!--<form id="fmSearch" name="fmSearch" method="post" action="">
        <table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><input name="iSearch" type="text" id="iSearch" value="Search..." size="20" maxlength="100" /></td>
            <td><input id="bSearch" name="bSearch" type="image" src="images/search.gif" class="button" /></td>
          </tr>
        </table>
      </form>-->
        <form id="fmSearch" name="fmSearch" method="post" action="">
          <label><span>
            <input id="iSearch" name="iSearch" type="text" class="keywords" maxlength="50" value="Search..." />
            </span>
            <input name="b" type="image" src="images/search.gif" class="button" />
          </label>
        </form>      
    </div>
  </div>

CSS 样式是:

#divMenu { width:100%; height:30px; background-image:url(../images/bar_menu.jpg); background-repeat:repeat-x; margin:0; padding:0; border-top:1px solid #999;}
#menu { width:75%; margin:0; padding:0; height:30px; position:absolute;}
#menu ul {float:left; margin:0; padding:0; list-style:none; font-size:0.8em;}
#menu ul li {float:left; margin:0; padding:0;}
#menu ul li a {line-height:25px; display: block; color:#fff; padding:2px 10px; text-decoration:none; z-index:500;}
#menu a:hover, #menu ul li a.active {margin:0; /*background-image: url(../images/img_nav.jpg);*/ background-color:#1D1D1D; background-repeat:repeat-x; z-index:510; color:#999;}
#menu ul li ul {display:none; position:absolute; background-color:#333; z-index:520; font-size:1em;}
#menu ul li:hover ul {display:block; z-index:530;}
#search { width:25%; padding:0; margin:0; float:right; height:30px; z-index:999;}
#search form #iSearch { height:16px; z-index:1000;}

问题:我的搜索框无法工作。它显示在页面上,但无法单击它并输入它,就好像它隐藏在某些东西下面一样。

有什么建议吗?

I'd like to implement bar where main menu is on the left and searchbox is on the right. My codes are:

  <div id="divMenu">
    <div id="menu">
      <ul>
        <li><a href="index.html" class="active"><span>Home</span></a></li>
        <li><a href="#"><span>About Us</span></a></li>
        <li><a href="#"><span>Events/Services</span></a>
          <ul>
            <li><a href="#"><span>submenu1</span></a></li>
            <li><a href="#"><span>submenu2</span></a></li>
            <li><a href="#"><span>submenu3</span></a></li>
          </ul>
        </li>
        <li><a href="#"><span>Ventures</span></a></li>
        <li><a href="#"><span>Testimonials</span></a></li>
        <li><a href="#"><span>Resources</span></a></li>
        <li><a href="#"><span>e-Commerce</span></a></li>
        <li><a href="#"><span>Contact Us</span></a></li>
      </ul>
    </div>
    <div id="search">
      <!--<form id="fmSearch" name="fmSearch" method="post" action="">
        <table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><input name="iSearch" type="text" id="iSearch" value="Search..." size="20" maxlength="100" /></td>
            <td><input id="bSearch" name="bSearch" type="image" src="images/search.gif" class="button" /></td>
          </tr>
        </table>
      </form>-->
        <form id="fmSearch" name="fmSearch" method="post" action="">
          <label><span>
            <input id="iSearch" name="iSearch" type="text" class="keywords" maxlength="50" value="Search..." />
            </span>
            <input name="b" type="image" src="images/search.gif" class="button" />
          </label>
        </form>      
    </div>
  </div>

CSS style are:

#divMenu { width:100%; height:30px; background-image:url(../images/bar_menu.jpg); background-repeat:repeat-x; margin:0; padding:0; border-top:1px solid #999;}
#menu { width:75%; margin:0; padding:0; height:30px; position:absolute;}
#menu ul {float:left; margin:0; padding:0; list-style:none; font-size:0.8em;}
#menu ul li {float:left; margin:0; padding:0;}
#menu ul li a {line-height:25px; display: block; color:#fff; padding:2px 10px; text-decoration:none; z-index:500;}
#menu a:hover, #menu ul li a.active {margin:0; /*background-image: url(../images/img_nav.jpg);*/ background-color:#1D1D1D; background-repeat:repeat-x; z-index:510; color:#999;}
#menu ul li ul {display:none; position:absolute; background-color:#333; z-index:520; font-size:1em;}
#menu ul li:hover ul {display:block; z-index:530;}
#search { width:25%; padding:0; margin:0; float:right; height:30px; z-index:999;}
#search form #iSearch { height:16px; z-index:1000;}

PROBLEM: My searchbox is not working. It is displayed on page but cannot click on it and type in it as if it's being hidden under something.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡淡離愁欲言轉身 2024-12-03 18:26:15

它在这里工作正常

http://jsfiddle.net/XFse7/

在导致问题之前必须是一些CSS。我认为如果它对你不起作用的话,它就在你的菜单下。请注意,z-index 仅适用于定位标签

位置:绝对、相对、固定等...

It's working fine here

http://jsfiddle.net/XFse7/

Must be some CSS before that causing the problem. I think it's under your menu if it's not working on your side. And note that z-index only works with positioned tag

position: absolute, relative, fixed, etc...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文