English 中文(简体)
jQuery UI - Accordion - Styling active header?
原标题:

Simple issue: I am using Accordion without any UI themes (just barebones, using my own CSS).

So far, so good, except that I cannot figure out how to set an "active" style for the currently selected header.

The jQuery code:

$("#menu").accordion({
  event: "mouseover",
  header: "a.top"
});

The HTML code:

<a href="#" class="top">XXX1</a>
<div class="sub">
   <a href="#">Subheading 1</a>
   <a href="#">Subheading 2</a>
   <a href="#">Subheading 3</a>
</div>

<a href="#" class="top">XXX2</a>
<div class="sub">
   <a href="#">Subheading 1</a>
   <a href="#">Subheading 2</a>
   <a href="#">Subheading 3</a>
</div>

This works great, except that I cannot find a way to define the styles for the active header without using ThemeRoller.

Manually setting the following styles in my CSS has no effect:

.ui-state-active
.ui-widget-content .ui-state-active
.ui-state-active a
.ui-state-active a:link
.ui-state-active a:visited

Assistance, please?

问题回答

I struggled with this one, too. I stripped away the h3 tags that were surrounding my a.nav links and specified header: .nav . In my css, I included "a.ui-state-active" to change the header of the open accordion div. For me prepending the "a" made the difference.

$("#menu").accordion({
    header: "a",
    event: mouseover,
    active:0
});

Use the "active" control. Not sure if it works without themeroller. The widget has a running count of all the "header" s used to create your menu. Index 0 is the first one xxx1, Index 1 is the second one xxx2, etc...

For anyone still using jQuery-ui just add this to your CSS:

.ui-accordion-header-active {
    background: red !important;
}

Just change the color or background you want!





相关问题
Allow user to change the default web part styles

I have a web part which uses many SharePoint controls like menu, SPGrid, tool bar etc. I want the user to be able to change the style by specifying an external CSS file. Can somebody tell me how I ...

using jqgrid style for usual Table in asp.net mvc

I d prefer using Table and td instead of JqGrid but i like JqGrid styles. has anyone used jqgrid style for usual Grid of asp.net MVC(i mean Table and td) before?

热门标签