Html 垂直分隔线 CSS

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4675371/
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 06:07:01  来源:igfitidea点击:

Vertical divider CSS

htmlcss

提问by 422

I am creating a vertical divider, that works fine. But the CSS is cumbersome.

我正在创建一个垂直分隔器,效果很好。但是CSS很麻烦。

The CSS is:

CSS是:

.headerDivider1 {
border-left:1px solid #38546d;height:80px;position:absolute;right:250px;top:10px;
}

.headerDivider2 {
border-left:1px solid #16222c;height:80px;position:absolute;right:249px;top:10px;
}

The HTML is:

HTML是:

<div class="headerDivider1"></div><div class="headerDivider2"></div>

The result is:

结果是:

alt text

替代文字

How could I tidy the HTML and CSS up?

我如何整理 HTML 和 CSS?

回答by amosrivera

.headerDivider {
     border-left:1px solid #38546d; 
     border-right:1px solid #16222c; 
     height:80px;
     position:absolute;
     right:249px;
     top:10px; 
}

<div class="headerDivider"></div>

回答by orlp

<div class="headerdivider"></div>

and

.headerdivider {
    border-left: 1px solid #38546d;
    background: #16222c;
    width: 1px;
    height: 80px;
    position: absolute;
    right: 250px;
    top: 10px;
}