html - 仅使用 CSS 的三 Angular 形边框

标签 html css

我想只使用 CSS 创建如下标题的背景:

enter image description here

我能够创建三 Angular 形,但无法正确定位它。 HTML 很简单:

<h1><a href="#">Link ...</a></h1>

这是 CSS:

h1{ 
    margin: 20px;
    width: 0px;
    height: 0px;
    border-style: solid;
    border-width: 50px 0 0 50px;
    border-color: transparent transparent transparent #0000ff;
}

JSFiddle 演示。 http://jsfiddle.net/yGsny/

最佳答案

这是您的问题的一种可能解决方案:

  h1{
        background:blue;
        line-height:30px;
        padding:0 20px;
        width:50px;
        position:relative;
    }
    a{color:white; text-decoration:none;}
    h1:before{
        position:absolute;
        left:100%;
        top:0;
        content:"";
        border:30px solid blue;
        border-width:0px 30px 30px 0px;
        border-color:transparent transparent blue transparent;
    }

Fiddle

关于html - 仅使用 CSS 的三 Angular 形边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14874031/

相关文章:

html - CSS 动画不透明度 (0) 回到 1

javascript - 在第一个事件监听器单击执行后退出 for 循环

html - 为什么宽度不是 :auto work

Jquery 如果条件 CSS

html - 最后一个跨度中的换行符但无法更改 HTML

html - 两个div同一行: why overflow: hidden; causes vertical offset?

Javascript 变量的值没有改变

html - 如何通过任何地方或外部点击关闭这个纯 css 弹出窗口?

html - Firefox 中的单行文本区域拒绝显示垂直滚动条

html - 高度以像素为单位,而不是百分比