简体   繁体   English

CSS边框底部缺少角

[英]CSS border bottom has missing corners

I would like to have a long border underneath my menu UL, but the "border-bottom" property on the list items does not work well: http://jsfiddle.net/BjGvp/ 我希望菜单UL下方有一个长边框,但是列表项上的“ border-bottom”属性无法正常工作: http : //jsfiddle.net/BjGvp/

#headermenu-left .menu {
    border-bottom: 4px solid #004B8D;
}

The border is interrupted at the corners by -I guess- the border-left and border-right properties not being there? 边界在拐角处被-我猜想-边界左和边界右属性不存在?

I can't put it on the <ul> element, because then the line runs too long. 我不能将其放在<ul>元素上,因为这样行会过长。

You can put it on the UL if you get rid of the width on it. 如果您消除了宽度,可以将其放在UL上。 Remove your last rule and use this: 删除最后一条规则,并使用此规则:

#headermenu-left {
    padding: 0;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    border-bottom: 4px solid #004B8D;
}

jsFiddle example jsFiddle示例

The problem, as you suggest, is the missing left and right borders, which have a width, but no color, so this distorts the appearance of the bottom border with the illusion of a missing notch. 正如您所建议的,问题是缺少左右边框,这些边框具有宽度,但是没有颜色,因此这会使底部边框的外观失真,并带有缺口的错觉。 To solve this you can simply define border-width: 0 for the element, and allow the border-bottom property to override that setting. 为了解决这个问题,您可以简单地为元素定义border-width: 0 ,并允许border-bottom属性覆盖该设置。

Demo . 演示

Unfortunately this is how borders work. 不幸的是,这就是边界的工作方式。 Those are the ends of your border-left, and border-right. 这些就是左边界和右边界的两端。 Here's a work around though, I added a div to the bottom of your list: 不过,这是一种解决方法,我在列表的底部添加了一个div:

(I also removed your width:70%; from your list) (我还从您的列表中删除了您的宽度:70%;)

#bluebar {
    position:absolute;
    bottom:0px;
    width:100%;
    height:5px;
    background-color:blue;
}

http://jsfiddle.net/BjGvp/6/ http://jsfiddle.net/BjGvp/6/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM