html - CSS - 没有填充的斜边框

标签 html css

我有一个 div,我需要一个左侧倾斜的边框,但我只找到了元素填充有颜色的解决方案。 我只需要边框,就像这张图:

enter image description here

我该怎么做?

我的实际代码:

HTML

<div class="arrow">
    <span id="time">30 mins</span>
    <img src="assets/up_arrow.png" />
</div>

CSS

.arrow {
    display: inline-block;
    text-align: right;
    text-decoration: none;
    margin-left: 35%;
    padding: 5px 0 5px 0;
    border-style: solid;
    border-width: 1px 0 1px 0;
    border-color: #929A9D transparent #929A9D transparent;
 }

 .arrow > img {
     vertical-align: middle;
     width: 12px;
     height: 12px;
 }

最佳答案

TRY THIS DEMO

HTML 和 CSS

#a {
    position: relative;
    width: 120px;
    padding: 10px 20px;
    font-size: 20px;
    position: relative;
    margin-left:50px;

    color: #2E8DEF;

    border: 3px solid #2E8DEF;
    border-left:0;
}
#a:before {
    content: " ";
    position: absolute;
    display: block;
    width: 50%;
    height: 100%;
    top: -3px;
    left: -30px;
    z-index: -1;

    border:3px solid #2E8DEF;
    border-right: 0px;

    transform-origin: bottom left;
    -ms-transform: skew(-30deg, 0deg);
    -webkit-transform: skew(-30deg, 0deg);
    transform: skew(-30deg, 0deg);
}
<div id="a">

    Hello

</div>

关于html - CSS - 没有填充的斜边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42853676/

相关文章:

css - 窗口中的 ExtJS 4 gridpanel 烦人的水平滚动条

html - 修复滚动时隐藏在其他 div 后面的 div

html - CSS: header bg 图片位置

html - 悬停 div 时更改跨度字体颜色和背景封面

html - 从 HTML 中提取文本的正则表达式

php - 为 Bootstrap 按钮组设置 Codeigniter 的 form_submit 样式

html - 如何做好视网膜准备?

css - 删除 css 中单元格之间的表格行和表格空间

python - 使用 LXML 仅按属性查询的 CSS 选择器

HTML/CSS float 问题