【问题标题】:Hyperlink on the baseline of a DIVDIV 基线上的超链接
【发布时间】:2010-09-10 15:47:24
【问题描述】:

我有以下标记:

<div class="ui-accordion ui-widget" style="margin: 10px 0px 12px 0px;">
    <h3 class="ui-helper-reset ui-corner-top ui-accordion-header ui-state-default" 
        style="height: 24px; font-weight: bold; padding: 5px 0px 0px 12px">Title</h3>
    <div class="ui-accordion-content-active ui-widget-content ui-corner-bottom accordionContent" 
         style="height:150px; padding: 8px 12px;">
        <ul>
            <li style="background-image:url('/_assets/images/image1.png');">
               <%= Html.ActionLink("Link 1", "Index", "Home") %>
            </li>
            <li style="background-image:url(/_assets/images/image2.png);">
               <%= Html.ActionLink("Link 2", "Index", "Home") %>
            </li>
            <li style="background-image:url(/_assets/images/image3.png);">
               <%= Html.ActionLink("Link 3", "Index", "Appointment") %>
            </li>
        </ul>
    </div>
</div>

在 Chrome 上呈现以下框(没有红色矩形)

我想在红色矩形的位置添加一个超链接。我该怎么做?

请注意,所有使用的样式都是内联的,并且类都来自 jquery UI 标准类。我不是设计师,也许这个标记可以优化。欢迎任何建议... :)

感谢您的帮助!

【问题讨论】:

    标签: html css jquery-ui


    【解决方案1】:

    &lt;div class="ui-accordion ...&gt; 内添加一个div 并使用以下样式:

    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 5em;
    height: 1.5em;
    

    [EDIT]div 必须有position: relative 否则它将不起作用(感谢Daniel[/EDIT]

    注意,你应该给盒子一个确定的尺寸;你不能让它自己“成长”。不过width: 100%; 没问题。

    另请注意,此 div 不会扩展父 div 的大小。如果手风琴太小,则最后一个条目将与您的链接重叠。解决方案是向手风琴添加一个具有必要高度的空div,以便为绝对定位的人腾出空间。

    【讨论】:

    • 确保将父 div 设置为 position: relative!
    • 感谢你们!没有 Aaron 的建议,链接被放置在页面底部;)
    猜你喜欢
    • 2012-03-06
    • 1970-01-01
    • 1970-01-01
    • 2020-05-16
    • 1970-01-01
    • 2019-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多