Jquery 自动完成样式
在设计 jQuery 自动完成插件的样式时,我将以下 HTML 代码硬连线到我的页面:
<ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem" style="z-index: 1; top: 0px; left: 0px; display: none; "></ul>
How can I disable style from being made through HTML and keep it done via CSS?我不认为我的 CSS 文件会覆盖该样式。
任何帮助都会做
While styling the jQuery autocomplete plugin, I get the following HTML code hardwired to my page:
<ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem" style="z-index: 1; top: 0px; left: 0px; display: none; "></ul>
How can I disable styling from being made through HTML and keep it done via CSS? I don't think my CSS files are overwriting that style.
Any help will do
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jQuery 自动完成需要设置一些内联样式,将下拉列表放置在文本框下方,并使其大小相等。
它不设置任何其他内容,因此完全由您通过设置添加到其中的类的样式(即
ui-autocomplete
)来提供它的视觉样式。建议
我想告诉您的是:设置显示的下拉列表的视觉效果,并且不必担心内联样式的定位和大小。
需要更改定位
如果您确实需要覆盖此元素的定位和大小,您可以随时将样式设置为
!important
。附加编辑
设置
margin-top
不会执行任何操作,因为它每次显示下拉菜单时都会计算位置。但你可以尝试设置这个:这实际上可以解决问题。
jQuery autocomplete needs to set some inline styles to position the drop down list under the text box and size it equally.
It doesn't set anything else, so it's completely up to you to provide visual styling of it by setting styles of those classes that are added to it (ie.
ui-autocomplete
).Advice
What I'm trying to tell you is this: set the visual aspects of the drop down list that gets displayed and don't worry about positioning and sizing inline styles.
Need to change positioning
If you do need to override positioning and sizing of this element you can always set your styles as
!important
.Additional edit
Setting
margin-top
doesn't do anything since it calculates position every single time it displays the drop down. But you can try setting this:This actually does the trick.
这可以通过对自动完成的“打开”方法进行一些更改来完成。
考虑这个例子:
通过这种方式改变自动完成的显示方式和位置。显示自动完成信息的“ul”具有“ui-autocomplete”类,您可以在此函数中操作其 css,以按照您想要的方式显示下拉列表。
This can be done by implementing some changes in the "open" method of Autocomplete.
consider this example:
In this way by changing how and where your autocomplete appears. The 'ul' that shows autocomplete info has class 'ui-autocomplete' you can manipulate its css in this function to show the drop down the way you want.