【问题标题】:How to create a div which is skewed on one side [duplicate]如何创建一个在一侧倾斜的 div [重复]
【发布时间】:2015-05-06 19:33:21
【问题描述】:

div 内会有一些文本,我应该能够将 div 的高度和宽度设置为自动,以便它根据里面的文本调整大小。 倾斜角度为 45*

【问题讨论】:

标签: html css css-shapes


【解决方案1】:

试试这个

CSS

.bar {
    height: 100px;
    width: 300px;
    background: #BC5859;
    display:inline-block;
    position: relative
}

.bar:before {
    display:inline-block;
    position: absolute;
    content:"";
    border-left: 100px solid #BC5859;
    border-bottom: 100px solid transparent;
    height: 0;
    width: 0px;
    right: -100px;
    top:0;
}

DEMO HERE

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-22
    • 2017-04-09
    • 2015-06-07
    • 2016-12-25
    • 2018-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多