jquery-ui 手风琴内的链接

发布于 2024-09-29 17:41:15 字数 1328 浏览 4 评论 0原文

我在 jquery-ui 手风琴 div 的内容中有一个链接。它可以工作,但格式与我的其他链接不同。我在 jquery-ui 手风琴页面 上找到了这个:

如果您在手风琴内容中有链接并使用 a 元素作为标题,请向它们添加一个类并将其用作标题,例如。标头:'a.header'。

但是,我不太确定该怎么做。我假设我需要更改手风琴的 .css 以使用这个新的 a.header 类作为标题,然后我的常规 a 元素将使用其余 a< 的 css我的网站上的 /code> 元素使用了什么?

这是手风琴的 .css:

    /* Accordion
----------------------------------*/
.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
.ui-accordion .ui-accordion-li-fix { display: inline; }
.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
/* IE7-/Win - Fix extra vertical space in lists */
.ui-accordion a { zoom: 1; }
.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; }
.ui-accordion .ui-accordion-content-active { display: block; }

I have a link within the content of a jquery-ui accordion div. It works, but is not formatted like the rest of my links. I found this on the jquery-ui accordion page:

If you have links inside the accordion content and use a-elements as headers, add a class to them and use that as the header, eg. header: 'a.header'.

However, I'm not really sure how to do this. I assume I need to change the .css for the accordion to use this new a.header class for the headers and then my regular a elements will use the css that the rest of the a elements on my site use?

Here's the .css for the accordion:

    /* Accordion
----------------------------------*/
.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
.ui-accordion .ui-accordion-li-fix { display: inline; }
.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
/* IE7-/Win - Fix extra vertical space in lists */
.ui-accordion a { zoom: 1; }
.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; }
.ui-accordion .ui-accordion-content-active { display: block; }

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

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

发布评论

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

评论(3

盛夏已如深秋| 2024-10-06 17:41:15

我建议使用像 firebug 这样的东西来检查你的元素。从那里您可以准确地找出 CSS 的哪一部分正在影响您的链接,以便您可以这样设计它。或者为链接提供自己的类名称,以按照您想要的方式设置其样式。如果您想直接进入 jquery UI CSS,也许可以研究一下其中包含“a”的标签样式,看看这是否能让您到达任何地方。

即:

.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
/* IE7-/Win - Fix extra vertical space in lists */
.ui-accordion a { zoom: 1; }
.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }

那些

I recommend using something like firebug to inspect your element. From there you can figure out exactly what part of that CSS is affecting your link so you can style it that way. That or give the link its own class name to style it the way you want. If you want to go directly to the jquery UI CSS, perhaps look into styling the tags with 'a' in them and see if that gets you anywhere.

ie:

.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
/* IE7-/Win - Fix extra vertical space in lists */
.ui-accordion a { zoom: 1; }
.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }

those ones

吲‖鸣 2024-10-06 17:41:15

您可以更改标头以使用标签以外的其他内容,然后在创建手风琴时设置属性:

<div id="accordion">
  <h3>My Header</h3>
     <div>My content with a <a href="#">link</a></div>
  <h3>Header Two</h3>
     <div>Some more stuff...</div>
</div>


$("#accordion").accordion({ header: 'h3' });

You can change your headers to use something other than an tag and then set the property when you're creating the accordion:

<div id="accordion">
  <h3>My Header</h3>
     <div>My content with a <a href="#">link</a></div>
  <h3>Header Two</h3>
     <div>Some more stuff...</div>
</div>


$("#accordion").accordion({ header: 'h3' });
柠栀 2024-10-06 17:41:15

我有一个网站需要执行此操作,我使用下面的代码来区分手风琴中的链接和标题:

标记:

<div id="accordion">
  <h3>
    <a href="MyNewPage.aspx" rel="newpage">Link To a New Page</a>
  </h3>
  <h3>
    <span class="name">Dental Providers</span>
  </h3>
    <div>
        Some Content with a <a href="#">Link to more stuff</a></div>
    </div>
</div>

JQuery:

     //redirect headers that link to new pages
     $('A[rel="newpage"]').click(function () {
         window.location=$(this).attr('href');
         return false;
     });
     //set up the accordion to use the h3 header
      $("#accordion").accordion({
         header: 'h3', 
         autoHeight: false,
         collapsible: true,
         fillSpace: false,
         icons: { 'header': 'ui-icon-triangle-1-e', 'headerSelected': 'ui-icon-triangle-1-s' }
     });

I have a website where I need to do this and I use the code below to accomplish differentiating between links and headers in the accordion:

Markup:

<div id="accordion">
  <h3>
    <a href="MyNewPage.aspx" rel="newpage">Link To a New Page</a>
  </h3>
  <h3>
    <span class="name">Dental Providers</span>
  </h3>
    <div>
        Some Content with a <a href="#">Link to more stuff</a></div>
    </div>
</div>

JQuery:

     //redirect headers that link to new pages
     $('A[rel="newpage"]').click(function () {
         window.location=$(this).attr('href');
         return false;
     });
     //set up the accordion to use the h3 header
      $("#accordion").accordion({
         header: 'h3', 
         autoHeight: false,
         collapsible: true,
         fillSpace: false,
         icons: { 'header': 'ui-icon-triangle-1-e', 'headerSelected': 'ui-icon-triangle-1-s' }
     });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文