如何使用填充制作插入边框

时间:2014-09-30 08:13:03

标签: html css border insets

我有这个JsFiddle:Click here

       <div id='menu'>
            <ul>
                <li><a class='styleanchor' href="${pageContext.request.contextPath}/mainpage/">
                    hone</a></li><!--  
                --><li><a class='styleanchor' href="${pageContext.request.contextPath}/verification/user/">asdsad</a></li><!--  
                --><li><a class='styleanchor' href="${pageContext.request.contextPath}/verification/user/">Replace this LOL</a></li><!--  
                --><li><a class='styleanchor' href=index.html>Replace this LOL</a></li><!--  
                --><li><a class='styleanchor' href=index.html>Replace this LOL</a></li><!--  
                --><li><a class='styleanchor' href="${pageContext.request.contextPath}/verification/store/"></a></li> 
            </ul>   
        </div>

我希望我的边框更像是图像中的边框:

enter image description here

正如你所看到的,它有一个插入边框,顶部和底部有填充,我猜。

如何使用css实现?我尝试将填充添加到 li ,但它没有用。

2 个答案:

答案 0 :(得分:1)

如果我理解这里的问题是DEMO

a.styleanchor:hover:before
    {
        content: "";
       position: absolute;
    display: inline-block;
    width: 0;
    height: 0;
    line-height: 0;
    border: 8px solid transparent;
    border-bottom: 8px solid #ffffff;
    left: 43%;
    right:43%;
    bottom: 0;
    }
#menu {
        text-align: center;
        position: relative;
        border-bottom: 1px solid gray;
        border-top: 1px solid gray;
        background: #ffffff; /* Old browsers */
        background: -moz-linear-gradient(top,  #ffffff 0%, #e5e5e5 100%); /* FF3.6+ */
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e5e5e5)); /* Chrome,Safari4+ */
        background: -webkit-linear-gradient(top,  #ffffff 0%,#e5e5e5 100%); /* Chrome10+,Safari5.1+ */
        background: -o-linear-gradient(top,  #ffffff 0%,#e5e5e5 100%); /* Opera 11.10+ */
        background: -ms-linear-gradient(top,  #ffffff 0%,#e5e5e5 100%); /* IE10+ */
        background: linear-gradient(to bottom,  #ffffff 0%,#e5e5e5 100%); /* W3C */
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
        border-radius: 10px 10px 0px 0px;

    }

答案 1 :(得分:0)

box-shadow: inset 0 0 5px 5px rgba(0, 0, 0, 0.1), inset 0 3px 2px 5px rgba(0, 0, 0, 0.1);