Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

background gradient & rotation create strange overlay

I use a bar with a rotated square as separator on my site.

The background-color is a gradient and fixed, so it creates a nice scroll effect, but when the rotated div reaches the view-port top, a strange gradient overlay appears.

Just look at it(you need to scroll slowly until the separator reaches the top of the view-port): http://jsfiddle.net/nff2fjf7/4/

body {
    height:800px;
}
.seperator {
    margin:100px 0 0 0;
    background-attachment: fixed;
    background-color: rgba(0, 157, 197, 1);
    background-image: -webkit-linear-gradient(top, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-image: -moz-linear-gradient(top, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-image: -o-linear-gradient(top, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-image: linear-gradient(to bottom, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    width:100%;
    height:40px;
    text-align: center;
}
.triangle {
    width:40px;
    height:40px;
    display: inline-block;
    margin: 10px 0;
    -moz-transform: rotate(45deg);
    -webkit-transform: rotate(45deg);
    -o-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
    background-attachment: fixed;
    background-color: rgba(0, 157, 197, 1);
    background-image: -webkit-linear-gradient(top, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-image: -moz-linear-gradient(top, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-image: -o-linear-gradient(top, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-image: linear-gradient(to bottom, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
}
<body>
    <div class="seperator">
        <div class="triangle"></div>
    </div>
</body>
like image 881
user4075462 Avatar asked Oct 11 '14 08:10

user4075462


1 Answers

body {
    height:800px;
}
.seperator {
    margin:100px 0 0 0;
    background-attachment: fixed;
    background-color: rgba(0, 157, 197, 1);
    background-image: -webkit-linear-gradient(top, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-image: -moz-linear-gradient(top, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-image: -o-linear-gradient(top, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-image: linear-gradient(to bottom, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    width:100%;
    height:40px;
    text-align: center;
}
.triangle {
    width:40px;
    height:40px;
    display: inline-block;
    margin: 10px 0;
    -moz-transform: rotate(45deg);
    -webkit-transform: rotate(45deg);
    -o-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
    background-attachment: fixed;
    background-color: rgba(0, 157, 197, 1);
    background-image: -webkit-linear-gradient(top, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-image: -moz-linear-gradient(top, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-image: -o-linear-gradient(top, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-image: linear-gradient(to bottom, rgba(0, 157, 197, 1), rgba(231, 52, 76, 1));
    background-repeat:no-repeat;
}
<body>
    <div class="seperator">
        <div class="triangle"></div>
    </div>
</body>

setting background-repeat:no-repeat on .triangle seems to cure it at the top of the page, but the issue is still present at the bottom :/

Fiddle

like image 149
andrew Avatar answered Oct 22 '22 13:10

andrew