html - 改变右边框的高度

标签 html css

<分区>

我的右边框是 100% 高度:

border-right:1px solid #000000;

enter image description here

我想让它更短:

enter image description here

是否可以在不改变 div 高度的情况下使用 CSS 实现?我需要 div 为 100% 高度并且只更改该边框。

最佳答案

您可以使用伪元素 来替换右边框。因为您可以选择它的大小/位置,所以您可以用它来模拟边框:

FIDDLE

HTML :

<div></div>

CSS:

div {
    height:200px;
    width:500px;
    background:gold;
    position:relative;
    border-top:10px solid grey;
    border-bottom:2px solid #000;
}
div:after {
    content:"";
    position:absolute;
    top:20%;
    right:0;
    width:2px;
    height:60%;
    background:#000;
}

支持 IE8 请参阅 caniuse

关于html - 改变右边框的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23260558/

相关文章:

html - 如何防止调整大小时换行?

html - 标题不显示背景图片

c# - ASP 转发器从 div 溢出

html - 如何在悬停状态下设置CSS绝对位置

CSS:什么/为什么将字体大小指定为字体大小:14px/1.31em?

html - 一侧有 CSS 平行四边形,里面有图像

javascript - 将 div 样式设置为最大高度

html - 将 div 附加到另一个 div 的右侧

jquery - 导航栏不会在 Twitter Bootstrap 3 模板中折叠和居中

jquery - 将灰度滤镜应用于 div