【问题标题】:RestructuredText - adding title attributes to linksRestructuredText - 为链接添加标题属性
【发布时间】:2011-06-01 12:12:48
【问题描述】:

我正在尝试在我的网站上使用从 reStructuredText 生成的 jQuery lightBox 实现。灯箱将图像周围的链接标题作为灯箱显示中图像的标题。

但是,我似乎无法在 reStructuredText 中找到在链接上提供标题属性的方法 - 有人知道这样做的方法吗?我的图像是这样定义的:

.. image:: image001.thumb.jpg
    :alt: Some alt text here
    :target: image001.jpg

所以我可以添加alt 属性,但不能添加标题。一种可能的替代方法是使用目标作为参考,如下所示:

.. image:: image001.thumb.jpg
    :alt: Some alt text here
    :target: image1_

.. _image1: image001.jpg

在后一种情况下,我不确定如何向底部定义的链接添加属性(如果可能的话)。

【问题讨论】:

    标签: html restructuredtext python-sphinx


    【解决方案1】:

    我假设(试试看!),初始化灯箱后灯箱不再需要标题属性。 因此,如果您想提供图像 alt-attributes 作为标题,则应该这样做,如果您在灯箱初始化后调用它:

    function alt_2_title () {
        $("img[alt]").each(function(){
            $(this).attr('title', $(this).attr('alt'));
        });
    });
    

    这会将每个具有 alt 属性的图像的 alt 复制到标题; 如果您只想修改几张图片,您可能会通过使用类似 ... 的方式来限制您的图片选择

    function alt_2_title (name_of_container) {
        $("img[alt]", "#"+name_of_container).each(function(){
            $(this).attr('title', $(this).attr('alt'));
        });
    });
    

    【讨论】:

    • 除了 jQuery 和灯箱,我想知道如何做 OP 要求的。不将 alt 复制到标题,只是能够设置标题以及 alt。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-01
    • 2014-10-24
    相关资源
    最近更新 更多