CSS angled linear gradient with “nested” gradient












1














This is what I'm trying to achieve:



desired-gradient



The light blue lines are just markers. I want an angle from a fixed px from the center (off to the left). And I also want the darker blue on the left to be a gradient too.



I can make the angle I need, but I'm stuck on placing it at a fixed point from the center, and making the darker part another angled gradient:






.topbar {
height: 150px;
background: rgb(28,25,84);
background: linear-gradient(-63deg, rgba(28,25,84,1) 50%, rgba(20,18,63,1) 0);
}

<div class="topbar"></div>





Thanks!










share|improve this question
























  • Can you use a repeating-linear-gradient?
    – Mr Lister
    Nov 20 at 20:43












  • Thanks @MrLister good to know about that, it got me a good enough effect if it wasn't for TermaniAfif going all the way
    – Dominic
    Nov 20 at 21:18
















1














This is what I'm trying to achieve:



desired-gradient



The light blue lines are just markers. I want an angle from a fixed px from the center (off to the left). And I also want the darker blue on the left to be a gradient too.



I can make the angle I need, but I'm stuck on placing it at a fixed point from the center, and making the darker part another angled gradient:






.topbar {
height: 150px;
background: rgb(28,25,84);
background: linear-gradient(-63deg, rgba(28,25,84,1) 50%, rgba(20,18,63,1) 0);
}

<div class="topbar"></div>





Thanks!










share|improve this question
























  • Can you use a repeating-linear-gradient?
    – Mr Lister
    Nov 20 at 20:43












  • Thanks @MrLister good to know about that, it got me a good enough effect if it wasn't for TermaniAfif going all the way
    – Dominic
    Nov 20 at 21:18














1












1








1







This is what I'm trying to achieve:



desired-gradient



The light blue lines are just markers. I want an angle from a fixed px from the center (off to the left). And I also want the darker blue on the left to be a gradient too.



I can make the angle I need, but I'm stuck on placing it at a fixed point from the center, and making the darker part another angled gradient:






.topbar {
height: 150px;
background: rgb(28,25,84);
background: linear-gradient(-63deg, rgba(28,25,84,1) 50%, rgba(20,18,63,1) 0);
}

<div class="topbar"></div>





Thanks!










share|improve this question















This is what I'm trying to achieve:



desired-gradient



The light blue lines are just markers. I want an angle from a fixed px from the center (off to the left). And I also want the darker blue on the left to be a gradient too.



I can make the angle I need, but I'm stuck on placing it at a fixed point from the center, and making the darker part another angled gradient:






.topbar {
height: 150px;
background: rgb(28,25,84);
background: linear-gradient(-63deg, rgba(28,25,84,1) 50%, rgba(20,18,63,1) 0);
}

<div class="topbar"></div>





Thanks!






.topbar {
height: 150px;
background: rgb(28,25,84);
background: linear-gradient(-63deg, rgba(28,25,84,1) 50%, rgba(20,18,63,1) 0);
}

<div class="topbar"></div>





.topbar {
height: 150px;
background: rgb(28,25,84);
background: linear-gradient(-63deg, rgba(28,25,84,1) 50%, rgba(20,18,63,1) 0);
}

<div class="topbar"></div>






css css3 linear-gradients css-gradients






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 21:23









Temani Afif

64k93675




64k93675










asked Nov 20 at 20:21









Dominic

26.4k106790




26.4k106790












  • Can you use a repeating-linear-gradient?
    – Mr Lister
    Nov 20 at 20:43












  • Thanks @MrLister good to know about that, it got me a good enough effect if it wasn't for TermaniAfif going all the way
    – Dominic
    Nov 20 at 21:18


















  • Can you use a repeating-linear-gradient?
    – Mr Lister
    Nov 20 at 20:43












  • Thanks @MrLister good to know about that, it got me a good enough effect if it wasn't for TermaniAfif going all the way
    – Dominic
    Nov 20 at 21:18
















Can you use a repeating-linear-gradient?
– Mr Lister
Nov 20 at 20:43






Can you use a repeating-linear-gradient?
– Mr Lister
Nov 20 at 20:43














Thanks @MrLister good to know about that, it got me a good enough effect if it wasn't for TermaniAfif going all the way
– Dominic
Nov 20 at 21:18




Thanks @MrLister good to know about that, it got me a good enough effect if it wasn't for TermaniAfif going all the way
– Dominic
Nov 20 at 21:18












1 Answer
1






active

oldest

votes


















1














You can have multipe background like follow:



I made the fixed distance from the center to be 200px which is the width of one gradient that is shifted by half 200px from the center:






.topbar {
height: 150px;
background:

/* the markers*/
linear-gradient(yellow,yellow) center/2px 100%,
linear-gradient(yellow,yellow) 25% 0/2px 100%,
linear-gradient(yellow,yellow) 75% 0/2px 100%,
/* the needed background*/
linear-gradient(-63deg, rgba(28,25,84,1) 50%,transparent 0) calc(50% - 100px) 0/200px 100%,
linear-gradient(rgba(28,25,84,1),rgba(28,25,84,1)) right/50% 100%,
linear-gradient(to bottom, red,blue);
background-repeat:no-repeat;
}

<div class="topbar"></div>





You can check this answer for more details on how background-position works with percentage values: Using percentage values with background-position on a linear gradient






share|improve this answer





















  • That's perfect, I didn't manage to get multiple gradients working thanks!
    – Dominic
    Nov 20 at 21:20










  • P.S. is it possible to angle the blue and red gradient 63deg also? @TermaniAfif
    – Dominic
    Nov 20 at 21:28








  • 1




    @Dominic yes, simply change the to bottom with what you want ... the blue red gradient is easiet one here because it's at the bottom layer and taking all the space
    – Temani Afif
    Nov 20 at 21:29











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400943%2fcss-angled-linear-gradient-with-nested-gradient%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can have multipe background like follow:



I made the fixed distance from the center to be 200px which is the width of one gradient that is shifted by half 200px from the center:






.topbar {
height: 150px;
background:

/* the markers*/
linear-gradient(yellow,yellow) center/2px 100%,
linear-gradient(yellow,yellow) 25% 0/2px 100%,
linear-gradient(yellow,yellow) 75% 0/2px 100%,
/* the needed background*/
linear-gradient(-63deg, rgba(28,25,84,1) 50%,transparent 0) calc(50% - 100px) 0/200px 100%,
linear-gradient(rgba(28,25,84,1),rgba(28,25,84,1)) right/50% 100%,
linear-gradient(to bottom, red,blue);
background-repeat:no-repeat;
}

<div class="topbar"></div>





You can check this answer for more details on how background-position works with percentage values: Using percentage values with background-position on a linear gradient






share|improve this answer





















  • That's perfect, I didn't manage to get multiple gradients working thanks!
    – Dominic
    Nov 20 at 21:20










  • P.S. is it possible to angle the blue and red gradient 63deg also? @TermaniAfif
    – Dominic
    Nov 20 at 21:28








  • 1




    @Dominic yes, simply change the to bottom with what you want ... the blue red gradient is easiet one here because it's at the bottom layer and taking all the space
    – Temani Afif
    Nov 20 at 21:29
















1














You can have multipe background like follow:



I made the fixed distance from the center to be 200px which is the width of one gradient that is shifted by half 200px from the center:






.topbar {
height: 150px;
background:

/* the markers*/
linear-gradient(yellow,yellow) center/2px 100%,
linear-gradient(yellow,yellow) 25% 0/2px 100%,
linear-gradient(yellow,yellow) 75% 0/2px 100%,
/* the needed background*/
linear-gradient(-63deg, rgba(28,25,84,1) 50%,transparent 0) calc(50% - 100px) 0/200px 100%,
linear-gradient(rgba(28,25,84,1),rgba(28,25,84,1)) right/50% 100%,
linear-gradient(to bottom, red,blue);
background-repeat:no-repeat;
}

<div class="topbar"></div>





You can check this answer for more details on how background-position works with percentage values: Using percentage values with background-position on a linear gradient






share|improve this answer





















  • That's perfect, I didn't manage to get multiple gradients working thanks!
    – Dominic
    Nov 20 at 21:20










  • P.S. is it possible to angle the blue and red gradient 63deg also? @TermaniAfif
    – Dominic
    Nov 20 at 21:28








  • 1




    @Dominic yes, simply change the to bottom with what you want ... the blue red gradient is easiet one here because it's at the bottom layer and taking all the space
    – Temani Afif
    Nov 20 at 21:29














1












1








1






You can have multipe background like follow:



I made the fixed distance from the center to be 200px which is the width of one gradient that is shifted by half 200px from the center:






.topbar {
height: 150px;
background:

/* the markers*/
linear-gradient(yellow,yellow) center/2px 100%,
linear-gradient(yellow,yellow) 25% 0/2px 100%,
linear-gradient(yellow,yellow) 75% 0/2px 100%,
/* the needed background*/
linear-gradient(-63deg, rgba(28,25,84,1) 50%,transparent 0) calc(50% - 100px) 0/200px 100%,
linear-gradient(rgba(28,25,84,1),rgba(28,25,84,1)) right/50% 100%,
linear-gradient(to bottom, red,blue);
background-repeat:no-repeat;
}

<div class="topbar"></div>





You can check this answer for more details on how background-position works with percentage values: Using percentage values with background-position on a linear gradient






share|improve this answer












You can have multipe background like follow:



I made the fixed distance from the center to be 200px which is the width of one gradient that is shifted by half 200px from the center:






.topbar {
height: 150px;
background:

/* the markers*/
linear-gradient(yellow,yellow) center/2px 100%,
linear-gradient(yellow,yellow) 25% 0/2px 100%,
linear-gradient(yellow,yellow) 75% 0/2px 100%,
/* the needed background*/
linear-gradient(-63deg, rgba(28,25,84,1) 50%,transparent 0) calc(50% - 100px) 0/200px 100%,
linear-gradient(rgba(28,25,84,1),rgba(28,25,84,1)) right/50% 100%,
linear-gradient(to bottom, red,blue);
background-repeat:no-repeat;
}

<div class="topbar"></div>





You can check this answer for more details on how background-position works with percentage values: Using percentage values with background-position on a linear gradient






.topbar {
height: 150px;
background:

/* the markers*/
linear-gradient(yellow,yellow) center/2px 100%,
linear-gradient(yellow,yellow) 25% 0/2px 100%,
linear-gradient(yellow,yellow) 75% 0/2px 100%,
/* the needed background*/
linear-gradient(-63deg, rgba(28,25,84,1) 50%,transparent 0) calc(50% - 100px) 0/200px 100%,
linear-gradient(rgba(28,25,84,1),rgba(28,25,84,1)) right/50% 100%,
linear-gradient(to bottom, red,blue);
background-repeat:no-repeat;
}

<div class="topbar"></div>





.topbar {
height: 150px;
background:

/* the markers*/
linear-gradient(yellow,yellow) center/2px 100%,
linear-gradient(yellow,yellow) 25% 0/2px 100%,
linear-gradient(yellow,yellow) 75% 0/2px 100%,
/* the needed background*/
linear-gradient(-63deg, rgba(28,25,84,1) 50%,transparent 0) calc(50% - 100px) 0/200px 100%,
linear-gradient(rgba(28,25,84,1),rgba(28,25,84,1)) right/50% 100%,
linear-gradient(to bottom, red,blue);
background-repeat:no-repeat;
}

<div class="topbar"></div>






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 at 21:14









Temani Afif

64k93675




64k93675












  • That's perfect, I didn't manage to get multiple gradients working thanks!
    – Dominic
    Nov 20 at 21:20










  • P.S. is it possible to angle the blue and red gradient 63deg also? @TermaniAfif
    – Dominic
    Nov 20 at 21:28








  • 1




    @Dominic yes, simply change the to bottom with what you want ... the blue red gradient is easiet one here because it's at the bottom layer and taking all the space
    – Temani Afif
    Nov 20 at 21:29


















  • That's perfect, I didn't manage to get multiple gradients working thanks!
    – Dominic
    Nov 20 at 21:20










  • P.S. is it possible to angle the blue and red gradient 63deg also? @TermaniAfif
    – Dominic
    Nov 20 at 21:28








  • 1




    @Dominic yes, simply change the to bottom with what you want ... the blue red gradient is easiet one here because it's at the bottom layer and taking all the space
    – Temani Afif
    Nov 20 at 21:29
















That's perfect, I didn't manage to get multiple gradients working thanks!
– Dominic
Nov 20 at 21:20




That's perfect, I didn't manage to get multiple gradients working thanks!
– Dominic
Nov 20 at 21:20












P.S. is it possible to angle the blue and red gradient 63deg also? @TermaniAfif
– Dominic
Nov 20 at 21:28






P.S. is it possible to angle the blue and red gradient 63deg also? @TermaniAfif
– Dominic
Nov 20 at 21:28






1




1




@Dominic yes, simply change the to bottom with what you want ... the blue red gradient is easiet one here because it's at the bottom layer and taking all the space
– Temani Afif
Nov 20 at 21:29




@Dominic yes, simply change the to bottom with what you want ... the blue red gradient is easiet one here because it's at the bottom layer and taking all the space
– Temani Afif
Nov 20 at 21:29


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400943%2fcss-angled-linear-gradient-with-nested-gradient%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python