css - 可以使用css3创建这样的背景吗?

标签 css css-transitions css-shapes

我需要在网页上设置这个背景,并且我正在使用这个图像来做到这一点,但我相信应该有一种方法可以使用 CSS3 来做到这一点,我知道你可以使用 css3 绘制对 Angular 线,但不确定如何使用 css3 为框的其余部分着色。

提前致谢!

menu background

最佳答案

是的,这是可能的。请随意更改类(class)以满足您的需求。

CSS:

body {
    position: relative;
}
.options_wrapper {
    width: 500px; /* Change to suit your needs */
    height: 80px; /* Change to suit your needs */
    position: absolute;
    top: 0;
    right: 0;
}
.options {
    width: 100%;
    height: 100%;
    box-shadow: 1px 0 rgba(0, 0, 0, 0.15);
    float: left;
    position: relative;
    overflow: hidden;
}
.options:before {
    width: 100%;
    height: 100%;
    background: #8A0808;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.5), inset 1px 0 rgba(255, 255, 255, 1);
    content:'';
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: top left;
    transform: skewX(45deg); /* Change to suit your needs */
}

HTML:

<div class="options_wrapper">
    <div class="options"></div>
</div>

这是一个演示:jsFiddle DEMO

关于css - 可以使用css3创建这样的背景吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33878889/

相关文章:

css - 摆脱动画上的 css 抖动

css - 如何在CSS3中实现梯形?

html - 箭头顶部和底部,如何优化 CSS?

html - <a href> 从 html 文件中发送电子邮件

css - 如何在 jQuery Mobile 中设置选择框高度?

css - css过滤器是否有可动画的过渡属性?

javascript - CSS 性能 - 如何评估 - 滚动时 float 按钮大小的动画(转换)(变换比例与高度/宽度)

javascript - 如何在使用辅助类添加和删除类时应用过渡

CSS3 label标签朝右使用位置或:after

CSS 扩展名与某些网站冲突