How to split page background with vertical polyline?
I found how to split page with vertical line - see jsfiddle:
The code is below -
body {
background-color: white;
}
#background {
position: fixed;
top: 0px;
left: 0px;
width: 50%;
height: 100%;
background-color: black;
z-index: 1;
}
#content {
position: relative;
z-index: 2;
padding: 30px;
text-align: center;
font-weight: bold;
color: red;
font-family: Arial, sans-serif;
}
Now I would like to replace vertical line with polyline to get something like this:
How can I do it with CSS?
P.S. I can not use background image, since polyline can be different (the points will have different coordinates).
html css background polyline
add a comment |
I found how to split page with vertical line - see jsfiddle:
The code is below -
body {
background-color: white;
}
#background {
position: fixed;
top: 0px;
left: 0px;
width: 50%;
height: 100%;
background-color: black;
z-index: 1;
}
#content {
position: relative;
z-index: 2;
padding: 30px;
text-align: center;
font-weight: bold;
color: red;
font-family: Arial, sans-serif;
}
Now I would like to replace vertical line with polyline to get something like this:
How can I do it with CSS?
P.S. I can not use background image, since polyline can be different (the points will have different coordinates).
html css background polyline
add a comment |
I found how to split page with vertical line - see jsfiddle:
The code is below -
body {
background-color: white;
}
#background {
position: fixed;
top: 0px;
left: 0px;
width: 50%;
height: 100%;
background-color: black;
z-index: 1;
}
#content {
position: relative;
z-index: 2;
padding: 30px;
text-align: center;
font-weight: bold;
color: red;
font-family: Arial, sans-serif;
}
Now I would like to replace vertical line with polyline to get something like this:
How can I do it with CSS?
P.S. I can not use background image, since polyline can be different (the points will have different coordinates).
html css background polyline
I found how to split page with vertical line - see jsfiddle:
The code is below -
body {
background-color: white;
}
#background {
position: fixed;
top: 0px;
left: 0px;
width: 50%;
height: 100%;
background-color: black;
z-index: 1;
}
#content {
position: relative;
z-index: 2;
padding: 30px;
text-align: center;
font-weight: bold;
color: red;
font-family: Arial, sans-serif;
}
Now I would like to replace vertical line with polyline to get something like this:
How can I do it with CSS?
P.S. I can not use background image, since polyline can be different (the points will have different coordinates).
html css background polyline
html css background polyline
asked Nov 13 '18 at 20:03
LA_LA_
7,47740140247
7,47740140247
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can consider multiple background to achieve this but it may be tricky to find the different values depending on the shape. It's basically a combination of triangle shape and rectangle shape above each other to create the final layer (changing the colors will help you identify each one)
body {
margin:0;
}
.box {
height:100vh;
background:
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 0 0/70% 120%,
linear-gradient(to top right,#000 49.8%,transparent 50%) 0 0/60% 70%,
linear-gradient(#000,#000) 0 100%/50% 31%,
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 55.3% 100%/10% 30.2%;
background-repeat:no-repeat;
}
<div class="box">
</div>
You can also consider clip-path
within a pseudo element and it will be easier (https://bennettfeely.com/clippy/)
body {
margin:0;
}
.box {
height:100vh;
position:relative;
}
.box:before {
content:"";
position:absolute;
top:0;
left:0;
bottom:0;
right:20%;
background:#000;
-webkit-clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
}
<div class="box">
</div>
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53288655%2fhow-to-split-page-background-with-vertical-polyline%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
You can consider multiple background to achieve this but it may be tricky to find the different values depending on the shape. It's basically a combination of triangle shape and rectangle shape above each other to create the final layer (changing the colors will help you identify each one)
body {
margin:0;
}
.box {
height:100vh;
background:
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 0 0/70% 120%,
linear-gradient(to top right,#000 49.8%,transparent 50%) 0 0/60% 70%,
linear-gradient(#000,#000) 0 100%/50% 31%,
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 55.3% 100%/10% 30.2%;
background-repeat:no-repeat;
}
<div class="box">
</div>
You can also consider clip-path
within a pseudo element and it will be easier (https://bennettfeely.com/clippy/)
body {
margin:0;
}
.box {
height:100vh;
position:relative;
}
.box:before {
content:"";
position:absolute;
top:0;
left:0;
bottom:0;
right:20%;
background:#000;
-webkit-clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
}
<div class="box">
</div>
add a comment |
You can consider multiple background to achieve this but it may be tricky to find the different values depending on the shape. It's basically a combination of triangle shape and rectangle shape above each other to create the final layer (changing the colors will help you identify each one)
body {
margin:0;
}
.box {
height:100vh;
background:
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 0 0/70% 120%,
linear-gradient(to top right,#000 49.8%,transparent 50%) 0 0/60% 70%,
linear-gradient(#000,#000) 0 100%/50% 31%,
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 55.3% 100%/10% 30.2%;
background-repeat:no-repeat;
}
<div class="box">
</div>
You can also consider clip-path
within a pseudo element and it will be easier (https://bennettfeely.com/clippy/)
body {
margin:0;
}
.box {
height:100vh;
position:relative;
}
.box:before {
content:"";
position:absolute;
top:0;
left:0;
bottom:0;
right:20%;
background:#000;
-webkit-clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
}
<div class="box">
</div>
add a comment |
You can consider multiple background to achieve this but it may be tricky to find the different values depending on the shape. It's basically a combination of triangle shape and rectangle shape above each other to create the final layer (changing the colors will help you identify each one)
body {
margin:0;
}
.box {
height:100vh;
background:
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 0 0/70% 120%,
linear-gradient(to top right,#000 49.8%,transparent 50%) 0 0/60% 70%,
linear-gradient(#000,#000) 0 100%/50% 31%,
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 55.3% 100%/10% 30.2%;
background-repeat:no-repeat;
}
<div class="box">
</div>
You can also consider clip-path
within a pseudo element and it will be easier (https://bennettfeely.com/clippy/)
body {
margin:0;
}
.box {
height:100vh;
position:relative;
}
.box:before {
content:"";
position:absolute;
top:0;
left:0;
bottom:0;
right:20%;
background:#000;
-webkit-clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
}
<div class="box">
</div>
You can consider multiple background to achieve this but it may be tricky to find the different values depending on the shape. It's basically a combination of triangle shape and rectangle shape above each other to create the final layer (changing the colors will help you identify each one)
body {
margin:0;
}
.box {
height:100vh;
background:
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 0 0/70% 120%,
linear-gradient(to top right,#000 49.8%,transparent 50%) 0 0/60% 70%,
linear-gradient(#000,#000) 0 100%/50% 31%,
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 55.3% 100%/10% 30.2%;
background-repeat:no-repeat;
}
<div class="box">
</div>
You can also consider clip-path
within a pseudo element and it will be easier (https://bennettfeely.com/clippy/)
body {
margin:0;
}
.box {
height:100vh;
position:relative;
}
.box:before {
content:"";
position:absolute;
top:0;
left:0;
bottom:0;
right:20%;
background:#000;
-webkit-clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
}
<div class="box">
</div>
body {
margin:0;
}
.box {
height:100vh;
background:
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 0 0/70% 120%,
linear-gradient(to top right,#000 49.8%,transparent 50%) 0 0/60% 70%,
linear-gradient(#000,#000) 0 100%/50% 31%,
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 55.3% 100%/10% 30.2%;
background-repeat:no-repeat;
}
<div class="box">
</div>
body {
margin:0;
}
.box {
height:100vh;
background:
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 0 0/70% 120%,
linear-gradient(to top right,#000 49.8%,transparent 50%) 0 0/60% 70%,
linear-gradient(#000,#000) 0 100%/50% 31%,
linear-gradient(to bottom right,#000 49.8%,transparent 50%) 55.3% 100%/10% 30.2%;
background-repeat:no-repeat;
}
<div class="box">
</div>
body {
margin:0;
}
.box {
height:100vh;
position:relative;
}
.box:before {
content:"";
position:absolute;
top:0;
left:0;
bottom:0;
right:20%;
background:#000;
-webkit-clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
}
<div class="box">
</div>
body {
margin:0;
}
.box {
height:100vh;
position:relative;
}
.box:before {
content:"";
position:absolute;
top:0;
left:0;
bottom:0;
right:20%;
background:#000;
-webkit-clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
clip-path: polygon(0 0, 72% 0, 59% 33%, 68% 62%, 47% 100%, 0 100%);
}
<div class="box">
</div>
edited Nov 13 '18 at 20:23
answered Nov 13 '18 at 20:18
Temani AfifTemani Afif
71.4k93979
71.4k93979
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53288655%2fhow-to-split-page-background-with-vertical-polyline%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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