简体   繁体   English

CSS的边框底边长度

[英]Border Bottom length in css

I am working on the footer section of a webpage. 我正在网页的页脚部分。 I am trying to limit the length of border bottom in css but unfortunately I am not able to restrict its length for some reasons. 我正在尝试限制CSS中边框底部的长度,但是由于某些原因,我无法限制边框的长度。 I have created the fiddle for it. 我为此创建了小提琴

The length of border-bottom which I want excatly is shown in this image . 我想要的边框底边的长度显示在此图像中

The code which I have written in the fiddle are: 我在小提琴中编写的代码是:

.footer p
{
  border-bottom: solid black;
}

The width (length) of your border will be exactly the width of your element. 边框的宽度(长度)将恰好是元素的宽度。 You can't set border to half of your element. 您不能将边框设置为元素的一半。

If you want to change lower the width of your border - lower the width of your element: 如果要更改,请降低边框的宽度-降低元素的宽度:

.footer p
{
  width: 50%;
  border-bottom: solid black;
}

Here is the jsfiddle: 这是jsfiddle:
https://jsfiddle.net/74zgg81d/ https://jsfiddle.net/74zgg81d/

Another option is to set a container for that p element with the desired width (and that p will use 100% of it's parent's width): 另一个选择是为该p元素设置一个具有所需宽度的容器(并且p将使用其父级宽度的100%):

<div class="footer">
    <div style="width: 150px">
        <p>
            ADDITIONAL INFO
        </p>
    </div>
</div> 

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

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