简体   繁体   English

我怎样才能使这个边界到最后?

[英]How can i make this border to the end?CSS

I have this short example: 我有一个简短的例子:

link 链接

CODE HTML: 代码HTML:

<div class="header">
    <div class="menu-collapse">MENU</div>
</div>

CODE CSS: 代码CSS:

.header{
    width:300px;
    height:auto;
    border:1px solid grey;
    padding: 5px 0 5px 0;
}

    .menu-collapse {
        display: table-cell;
        vertical-align: middle;
        border-right: 2px solid red;
        padding: 0px 10px 0 10px;
        height: 100%;
}

My problem is that border (red border) is not until the end header. 我的问题是边框(红色边框)直到结尾标题才出现。

There is a space both top and bottom in. CSS code in the header must remain exactly the same 顶部和底部都有一个空格。标头中的CSS代码必须保持完全相同

Can you help me to solve this problem? 您能帮我解决这个问题吗?

Thanks in advance! 提前致谢!

remove padding from the .header class. 从.header类中删除填充。 This space is header's padding. 该空间是标题的填充。 And add the padding to the .menu-collapse class. 并将填充添加到.menu-collapse类。

.header{
    width:300px;
    height:auto;
    border:1px solid grey;    
}

    .menu-collapse {
        display: table-cell;
        vertical-align: middle;
        border-right: 2px solid red;
        padding: 5px 10px;
        height: 100%;
}

Here is the fiddle . 这是小提琴

Remove Padding from header and provide top & bottom padding too to menu-collapse . header删除Padding,并为menu-collapse提供top & bottom padding Try this: 尝试这个:

 .header{ width:300px; height:auto; border:1px solid grey; } .menu-collapse { display: table-cell; vertical-align: middle; border-right: 2px solid red; padding: 5px; height: 100%; } 
 <div class="header"> <div class="menu-collapse">MENU</div> </div> 

set padding 0px for header and add line-height 设置标题的填充0px并添加line-height

.header{
    width:300px;
    height:auto;
    border:1px solid grey;
    padding: 0;
    line-height:25px;
}

Check this: https://jsfiddle.net/6ae7vumn/3/ 检查此: https : //jsfiddle.net/6ae7vumn/3/

.header{
    width:300px;
    height:auto;
    border:1px solid grey;
}

.menu-collapse {
    display: table-cell;
    vertical-align: middle;
    border-right: 2px solid red;
    padding: 15px 5px;
    height: 100%;}

You dont need to use padding in header 您不需要在标题中使用填充

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

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