无法破解pass-css插件以使两个输入元素出现在一行中

Cannot hack pass css plugin to make two input elements appears in-line?

本文关键字:元素 一行 输入 两个 插件 pass-css 破解      更新时间:2024-04-16

我正在使用下拉菜单的插件。插件的链接在这里。。我想把这个代码添加到已经制作好的html代码中,但首先我想测试一下。到目前为止,一切都很好,直到我尝试制作两个小部件副本,并使它们并排出现。默认情况下,input元素显示为内联,但插件css正在将其向下推,使其变成单列(堆叠)。我不希望这样。这是HTML代码。

HTML

<head>
<script type="text/javascript" src="lib/jquery-1.2.6.js"></script>
<script type="text/javascript" src="lib/jquery.mcdropdown.js"></script>
<!---// load the mcDropdown CSS stylesheet //--->
<link type="text/css" href="css/jquery.mcdropdown.css" rel="stylesheet" media="all" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
</head>

<body>
<ul id="categorymenu" class="mcdropdown_menu">
  <li rel="1">
    Arts &amp; Humanities
    <ul>
      <li rel="2">
        Photography
        <ul>
          <li rel="3">
            3D
          </li>
          <li rel="4">
            Digital
          </li>
        </ul>
      </li>
      <li rel="5">
        History
      </li>
      <li rel="6">
        Literature
      </li>
    </ul>
  </li>
  <li rel="7">
    Business &amp; Economy
  </li>
  <li rel="8">
    Computers &amp; Internet
  </li>
  <li rel="9">
    Education
  </li>
  <li rel="11">
    Entertainment
    <ul>
      <li rel="12">
        Movies
      </li>
      <li rel="13">
        TV Shows
      </li>
      <li rel="14">
        Music
      </li>
      <li rel="15">
        Humor
      </li>
    </ul>
  </li>
  <li rel="10">
    Health
  </li>
</ul>
<div class="test"> <input type="text" class="category" name="category" id="category" value="" />
<input type="text" class="category" name="category" id="category_1" value="" /></div>

JAVASCRIPT

<script>
$(document).ready(function (){
  $("#category").mcDropdown("#categorymenu");
    $("#category_1").mcDropdown("#categorymenu");
});
</script>
</body>
</html>

CSS PLUGIN

/* 
    styles for the psuedo-select box 
*/
div.mcdropdown {
    position: absolute;
    border: 1px solid #8e9daa;
    padding: 1px;
    display: -moz-inline-block;
    display: inline-block;
    width: 408px;
    height: 14px;
    padding: 2px;
}
/* style either the input or div where the plug-in is attached to */
div.mcdropdown input, 
div.mcdropdown div {
    position: absolute;
    background-color: #fff;
    left: 0;
    top: 0;
    width: 98%;
    border: 0;
    padding: 2px 0 0 3px;
    font: 11px Arial, Helvetica, sans-serif;
}
div.mcdropdown a {
    position: absolute;
    right: 1px;
    top: 1px;
    background: transparent url(../images/mcdropdown/mcdd_select_button_sprite.gif) no-repeat top left;
    display: -moz-inline-block;
    display: inline-block;
    height: 16px;
    width: 15px;
    text-decoration: none;
    font-size: 0pt;
    z-index: 2;
    outline: 0;
}
div.mcdropdown a:hover, div.mcdropdown a:focus {
    background-position: 0% -16px;
}
div.mcdropdown a:active {
    background-position: 0% -32px;
    outline: none; /* hide dotted outline in Firefox */
}
div.mcdropdownDisabled {
    background-color: #e1e0e0;
    filter:alpha(opacity=75);
    -moz-opacity: 0.75;
    opacity: 0.75;
    -khtml-user-select: none;
    -o-user-select: none;
    -moz-user-select: none;
    -moz-user-focus: ignore; 
    -moz-user-input: disabled; 
}
div.mcdropdownDisabled input {
    cursor: default;
}
div.mcdropdownDisabled a:hover, div.mcdropdownDisabled a:focus {
    background-position: 0 0;
    cursor: default;
}
/* 
    styles for the dropdown menu 
*/
ul.mcdropdown_menu {
    display: none;
    margin: 0px;
    padding: 0px;
    list-style-type: none;
    /* float so we can calculate the size of the columns */
    float: left;
    clear: both;
    z-index: 10000;
    -khtml-user-select: none;
    -o-user-select: none;
    -moz-user-select: none;
    -moz-user-focus: ignore; 
    -moz-user-input: disabled; 
}
ul.mcdropdown_menu ul {
    display: none;
    font: 11px Arial, Helvetica, sans-serif;
    /* float so we can calculate the size of the columns */
/*
    float: left;
*/
}
/* -- Sub-Menus -- */
ul.mcdropdown_menu ul {
    position: absolute;
    list-style-type: none;
    margin: 0px;
    margin-left: 30px;
    padding: 0px;
    z-index: 10000;
}
ul.mcdropdown_menu ul li {
    margin: 0px;
    min-width: 150px;
    _width: 150px; /* ie6 min-width hack */
}

/* color schema */
ul.mcdropdown_menu {
/*
    height: 19px;
*/
    height: auto;
    background-color: #e1e0e0;
    padding: 5px 5px;
    /* define font here for IE6 */
    font: 11px Arial, Helvetica, sans-serif;
}
ul.mcdropdown_menu li {
    padding: 2px 20px 2px 6px;
    /* this is needed to ensure that all browsers have the same line-height--fixes issues in Chrome (Mac) and IE10 */
    line-height: 14px;
}
/* we don't use "ul.mcdropdown_menu > li" here so that IE6 knows how to style the root level */
ul.mcdropdown_menu li.mc_root {
    cursor: pointer;
    white-space: nowrap;
    color: #666;
    border-top: 1px solid #fff;
    padding: 2px 20px 2px 6px;
    margin: 0 10px;
}
ul.mcdropdown_menu > li.mc_endcol {
    border-bottom: 1px solid #fff;
}
/* this is for IE6 only */
ul.mcdropdown_menu li.mc_hover {
    background-color: #ccc !important;
}
ul.mcdropdown_menu > li:hover {
    border-top: 1px solid #999;
    background-color: #999 !important;
    color: #fff;
}
ul.mcdropdown_menu > li:hover.mc_endcol {
    border-bottom: 1px solid #999;
}
ul.mcdropdown_menu > li:hover + li:not(.mc_firstrow) {
    border-top: 1px solid #999;
}
ul.mcdropdown_menu li.mc_parent {
    padding-right: 20px !important;
    background: url(../images/mcdropdown/mcdd_icon_normal.gif) no-repeat 100% 50%;
}
ul.mcdropdown_menu li:hover.mc_parent {
    background: #999 url(../images/mcdropdown/mcdd_icon_hover.gif) no-repeat 100% 50% !important;
    color: #fff !important;
}
ul.mcdropdown_menu ul {
    background: #f0f0f0;
    /* add a slight border for better visualization of deep menus */
    border: 1px solid #d0d0d0;
    padding-bottom: 10px;
    /* IE 6/7 will bleed through the background color if we don't set the visibility to hidden */
    visibility: hidden;
}
ul.mcdropdown_menu ul li {
    background: #f0f0f0;
    padding-left: 16px !important;
    border-top: 1px solid #fff;
    color: #666;
    white-space: nowrap;
}
ul.mcdropdown_menu ul li.mc_firstrow {
    border-top: 1px solid #f0f0f0;
}
ul.mcdropdown_menu ul li.mc_endcol {
    border-bottom: 1px solid #fff;
}
ul.mcdropdown_menu ul li:hover {
    background-color: #d6d6d6;
    border-top: 1px solid #dedede;
    color: #666;
}
ul.mcdropdown_menu ul li.mc_endcol:hover {
    border-bottom: 1px solid #dedede;
}
ul.mcdropdown_menu ul li:hover + li:not(.mc_firstrow) {
    border-top: 1px solid #dedede;
}
/*
 * drop down shadows
 */
div.mcdropdown_shadow {
    display: none;
    position: absolute;
    margin: 3px 0 0 3px;
    /* for IE6, we use just a square transparent image */
    background: #000;
    filter :alpha(opacity=33);
}
/* ie6 ignores this selector */
html>body div.mcdropdown_shadow {
    /* let's use a transparent PNG */
    margin: 5px 0 0 5px;
    padding: 5px 0 0 5px;
    background: transparent url(../images/mcdropdown/shadow.png) right bottom no-repeat !important;
    /* remove the filter for IE7 */
    filter: none;
}
/* 
 * styles for the dropdown menu 
 */
/* autocomplete styles */
ul.mcdropdown_autocomplete {
    display: block;
  position: absolute;
    height: auto;
    max-height: 210px;
  overflow-x: hidden;
    overflow-y: auto;
  clear: both;
    padding: 5px 10px;
    background-color: #e1e0e0;
    z-index: 10000;
    margin: 0px;
    list-style-type: none;
    width: 392px;
    font: 11px Arial, Helvetica, sans-serif;
}
ul.mcdropdown_autocomplete ul {
    display: none;
    list-style-type: none;
    margin: 0px;
    padding: 0px;
}
ul.mcdropdown_autocomplete ul li {
    margin: 0px;
}
ul.mcdropdown_autocomplete li {
  display: block;
    font: 11px Arial, Helvetica, sans-serif;
    cursor: pointer;
    white-space: nowrap;
    color: #666;
    border-top: 1px solid #fff;
    padding: 2px 26px 2px 6px;
}
ul.mcdropdown_autocomplete li.mc_endcol {
    border-bottom: 1px solid #fff;
}
ul.mcdropdown_autocomplete li.mc_parent {
    padding-right: 20px !important;
    background: url(../images/mcdropdown/mcdd_icon_normal.gif) no-repeat 100% 50%;
}
ul.mcdropdown_autocomplete li.mc_hover {
    border-top: 1px solid #999;
    background-color: #999 !important;
    color: #fff;
}
ul.mcdropdown_autocomplete li.mc_hover_parent {
    background: #999 url(../images/mcdropdown/mcdd_icon_hover.gif) no-repeat 100% 50% !important;
    color: #fff !important;
}

我尝试过的失败的

.category {
  float: left;
  display: block;
}
#category_1 {
  margin-left: 20px; /* or space you want..*/
}
    <style>
        #category, #category_1{
            display: inline;
        }
    </style>

请引导我。谢谢。

将其添加到您的css中:

div.test > div { 
    float: left; 
    width: 408px; 
    margin-right: 20px; 
}

根据插件页面:

注意:应用插件的初始元素已销毁并用具有相同id属性的新输入元素替换。虽然mcDropdown()方法不会破坏jQuery链,但它确实有效地返回了一个"脏"引用(因为原始元素已不存在。)因此,您需要确保mcDropdown()方法是链中的最后一个调用。此外,如果如果计划缓存对元素的引用,则需要在启动小部件后创建缓存实例。

老实说,我甚至不确定这是否有关联。

但是,当我看到你的代码(尽管没有像广告中那样运行)时,它正按照你想要的方式排列。给你一把小提琴,让你看看我看到了什么。

当然,请记住,我不确定为什么它不能正常工作。我把它放在桌面上,原样复制了整个示例,但仍然一无所获。但是输入框很漂亮也很整洁:)

我确实注意到你漏掉了jquery.bgiframe.js文件,但我认为没有必要。