是否可以使用更大的底部填充为箭头制作href

时间:2015-01-17 11:05:11

标签: html css href css-shapes

我想在悬停时使用箭头图像制作顶部菜单,它将显示在下一个div的边框线上。

My fast made fiddle:

和我想做的图像

HTML

<div class="wrapper">
    <img src="" alt="" id="logo" />
    <ul id="topmenu">
        <li><a href="" title="">item 1</a></li>
        <li><a href="" title="">item 2</a></li>
        <li><a href="" title="">item 3</a></li>
    </ul>
</div>

<div class="full-width-page">
    <div class="wrapper">
        <div id="header-image">
            image with content goes here
        </div>
    </div>
</div>

CSS

.wrapper {
    width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.full-width-page {
    width: 100%;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    overflow: hidden;
}

#logo {
    float: left;
    width: 200px;
    height: 30px;
    background-color: gray;
    margin-top: 15px;
}

#topmenu {
    float: right;
    display: block;
    list-style: none;
    margin: 0px;
    padding: 20px;
}

#topmenu li {
    display: inline-block;
    padding-bottom: 20px;
}

#topmenu li a:hover {
    background-image: url(http://www.ristatebassmasters.com/images/smallDownArrow.gif);
    background-repeat: no-repeat;
    background-position: center 8px;
}

#header-image {
    height: 200px;
    line-height: 200px;
}

我知道有一个解决方案可以将菜单设置为position: absolute。然后在href上创建padding-bottom将进一步向下推动箭头,但是当菜单将被定位为绝对值时,我将无法使用float: right推送它。

2 个答案:

答案 0 :(得分:1)

这是您想要的 updated fiddle

CSS

#topmenu {
    display: block;
    list-style: none;
    margin: 0px;
    padding: 20px;
    position: absolute;
    right: 0;
    top: 0;
}
#topmenu li {
    display: inline-block;
    padding-bottom: 20px;
}

#topmenu li a{
    padding-bottom: 30px; 
}
#topmenu li a:hover {
    background-image: url(http://www.ristatebassmasters.com/images/smallDownArrow.gif);
    background-repeat: no-repeat;
    background-position: center 32px;

}
#header-image {
    height: 200px;
    line-height: 200px;
}

答案 1 :(得分:0)

我已从菜单中为padding-bottom元素添加了<a>,其工作方式与here

相同

检查并写下你是否可以:)