Html li 元素的下边框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12354456/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:45:30  来源:igfitidea点击:

Bottom border on li element

htmlcsshtml-lists

提问by oliverbj

I am trying to add a bottom border to my li elements. This is my css:

我正在尝试为我的 li 元素添加一个底部边框。这是我的CSS:

.menu{
    text-align:right;
}
.menu li{
    padding:5px;
    text-transform: uppercase;
    display:inline; 
    list-style-type:none;
    list-style-position: inside;

    border-bottom: 1px solid red;
}

And my HTML:

还有我的 HTML:

    <div class="menu">
        <ul>
            <li>Home</li>
            <li>Home</li> 
            <li>Home</li> 
            <li>Home</li> 
            <li>Testimonials</li>
            <li>About Us</li>
            <li>Contact Us</li>
        </ul>
    </div>

For some reason, no bottom border is added. I can add a border to the right and left, but not the bottom. What am I doing wrong?

出于某种原因,没有添加底部边框。我可以在左右两侧添加边框,但不能在底部添加边框。我究竟做错了什么?

采纳答案by blasteralfred Ψ

try adding;

尝试添加;

html, body{
  margin: 0;
  padding: 0;
}

Your code is working fine herewithout any changes.

您的代码在这里工作正常无需任何更改。

回答by Web Designer cum Promoter

I understand clearly about your need. the solutions is given below just change bottom as right. please test and give feedback.

我清楚地了解您的需求。下面给出了解决方案,只需更改底部即可。请测试并提供反馈。

.menu li{    
    padding:5px;
    text-transform: uppercase;
    display:inline;
    list-style-type:none;
    list-style-position: inside;
    border-right: 1px solid red;
}