Can I use CSS to distort borders so they look like sketched?
I have bordered boxes (div) which I want to make look like a sketch, i.e. with the borders not drawn as straight lines, but slightly distorted, as if drawn by hand.
Illustration:

Can this be done using CSS transformation or similar?
css css-transforms
add a comment |
I have bordered boxes (div) which I want to make look like a sketch, i.e. with the borders not drawn as straight lines, but slightly distorted, as if drawn by hand.
Illustration:

Can this be done using CSS transformation or similar?
css css-transforms
I don't think so. I guess you could just use an image.
– Angel Politis
Apr 29 '17 at 10:45
add a comment |
I have bordered boxes (div) which I want to make look like a sketch, i.e. with the borders not drawn as straight lines, but slightly distorted, as if drawn by hand.
Illustration:

Can this be done using CSS transformation or similar?
css css-transforms
I have bordered boxes (div) which I want to make look like a sketch, i.e. with the borders not drawn as straight lines, but slightly distorted, as if drawn by hand.
Illustration:

Can this be done using CSS transformation or similar?
css css-transforms
css css-transforms
asked Apr 29 '17 at 10:38
not2savvynot2savvy
493417
493417
I don't think so. I guess you could just use an image.
– Angel Politis
Apr 29 '17 at 10:45
add a comment |
I don't think so. I guess you could just use an image.
– Angel Politis
Apr 29 '17 at 10:45
I don't think so. I guess you could just use an image.
– Angel Politis
Apr 29 '17 at 10:45
I don't think so. I guess you could just use an image.
– Angel Politis
Apr 29 '17 at 10:45
add a comment |
2 Answers
2
active
oldest
votes
You can use CSS Border Images.
Here is an example on w3schools website.
And here's a code example:
#borderimg {
/* You can also use border-top or border-bottom to target the side you want affected */
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(border.png) 50 round; /* Safari 3.1-5 */
-o-border-image: url(border.png) 50 round; /* Opera 11-12.1 */
border-image: url(border.png) 50 round;
}
1
I think the explanation at w3schools is not very good. I can recommend this article which gives a very detailed explanation. And this site provides a very helpful tool to find the best values for border-image-slice and other properties.
– not2savvy
Apr 29 '17 at 16:24
@not2savvy I know what you mean, w3schools tend to be quite vague at times. But hey, they have a lot to do I guess.
– Kitanga Nday
Apr 29 '17 at 17:44
1
You're probably right. Here's my implementation, just for reference: Sketched box example (click toggle style to set light background)
– not2savvy
May 1 '17 at 12:16
add a comment |
This article on hand-drawn borders gives a great example of achieving this effect on buttons using only CSS by using large elliptical rounded corners (through the CSS border-radius property). It probably won't work as well for large div elements.
Example adapted from the article:
button {
background:transparent;
padding:0.5rem 0.5rem;
margin:0 0.5rem;
font-size:1rem;
border-top-left-radius: 255px 15px;
border-top-right-radius: 15px 225px;
border-bottom-right-radius: 225px 15px;
border-bottom-left-radius:15px 255px;
}
button:hover{
box-shadow:2px 8px 4px -6px hsla(0,0%,0%,.3);
}
button.lined.thick{
border:solid 3px #41403E;
}
button.dotted.thick{
border:dotted 3px #41403E;
}
button.dashed.thick{
border:dashed 3px #41403E;
}
button.lined.thin{
border:solid 2px #41403E;
}
button.dotted.thin{
border:dotted 2px #41403E;
}
button.dashed.thin{
border:dashed 2px #41403E;
}<button class='lined thick'>Lined Thick</button>
<button class='dotted thick'>Dotted Thick</button>
<button class='dashed thick'>Dashed Thick</button>
<div> </div>
<button class='lined thin'>Lined Thin</button>
<button class='dotted thin'>Dotted Thin</button>
<button class='dashed thin'>Dashed Thin</button>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%2f43694588%2fcan-i-use-css-to-distort-borders-so-they-look-like-sketched%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use CSS Border Images.
Here is an example on w3schools website.
And here's a code example:
#borderimg {
/* You can also use border-top or border-bottom to target the side you want affected */
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(border.png) 50 round; /* Safari 3.1-5 */
-o-border-image: url(border.png) 50 round; /* Opera 11-12.1 */
border-image: url(border.png) 50 round;
}
1
I think the explanation at w3schools is not very good. I can recommend this article which gives a very detailed explanation. And this site provides a very helpful tool to find the best values for border-image-slice and other properties.
– not2savvy
Apr 29 '17 at 16:24
@not2savvy I know what you mean, w3schools tend to be quite vague at times. But hey, they have a lot to do I guess.
– Kitanga Nday
Apr 29 '17 at 17:44
1
You're probably right. Here's my implementation, just for reference: Sketched box example (click toggle style to set light background)
– not2savvy
May 1 '17 at 12:16
add a comment |
You can use CSS Border Images.
Here is an example on w3schools website.
And here's a code example:
#borderimg {
/* You can also use border-top or border-bottom to target the side you want affected */
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(border.png) 50 round; /* Safari 3.1-5 */
-o-border-image: url(border.png) 50 round; /* Opera 11-12.1 */
border-image: url(border.png) 50 round;
}
1
I think the explanation at w3schools is not very good. I can recommend this article which gives a very detailed explanation. And this site provides a very helpful tool to find the best values for border-image-slice and other properties.
– not2savvy
Apr 29 '17 at 16:24
@not2savvy I know what you mean, w3schools tend to be quite vague at times. But hey, they have a lot to do I guess.
– Kitanga Nday
Apr 29 '17 at 17:44
1
You're probably right. Here's my implementation, just for reference: Sketched box example (click toggle style to set light background)
– not2savvy
May 1 '17 at 12:16
add a comment |
You can use CSS Border Images.
Here is an example on w3schools website.
And here's a code example:
#borderimg {
/* You can also use border-top or border-bottom to target the side you want affected */
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(border.png) 50 round; /* Safari 3.1-5 */
-o-border-image: url(border.png) 50 round; /* Opera 11-12.1 */
border-image: url(border.png) 50 round;
}
You can use CSS Border Images.
Here is an example on w3schools website.
And here's a code example:
#borderimg {
/* You can also use border-top or border-bottom to target the side you want affected */
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(border.png) 50 round; /* Safari 3.1-5 */
-o-border-image: url(border.png) 50 round; /* Opera 11-12.1 */
border-image: url(border.png) 50 round;
}
edited Sep 2 '18 at 18:53
answered Apr 29 '17 at 10:55
Kitanga NdayKitanga Nday
1,246921
1,246921
1
I think the explanation at w3schools is not very good. I can recommend this article which gives a very detailed explanation. And this site provides a very helpful tool to find the best values for border-image-slice and other properties.
– not2savvy
Apr 29 '17 at 16:24
@not2savvy I know what you mean, w3schools tend to be quite vague at times. But hey, they have a lot to do I guess.
– Kitanga Nday
Apr 29 '17 at 17:44
1
You're probably right. Here's my implementation, just for reference: Sketched box example (click toggle style to set light background)
– not2savvy
May 1 '17 at 12:16
add a comment |
1
I think the explanation at w3schools is not very good. I can recommend this article which gives a very detailed explanation. And this site provides a very helpful tool to find the best values for border-image-slice and other properties.
– not2savvy
Apr 29 '17 at 16:24
@not2savvy I know what you mean, w3schools tend to be quite vague at times. But hey, they have a lot to do I guess.
– Kitanga Nday
Apr 29 '17 at 17:44
1
You're probably right. Here's my implementation, just for reference: Sketched box example (click toggle style to set light background)
– not2savvy
May 1 '17 at 12:16
1
1
I think the explanation at w3schools is not very good. I can recommend this article which gives a very detailed explanation. And this site provides a very helpful tool to find the best values for border-image-slice and other properties.
– not2savvy
Apr 29 '17 at 16:24
I think the explanation at w3schools is not very good. I can recommend this article which gives a very detailed explanation. And this site provides a very helpful tool to find the best values for border-image-slice and other properties.
– not2savvy
Apr 29 '17 at 16:24
@not2savvy I know what you mean, w3schools tend to be quite vague at times. But hey, they have a lot to do I guess.
– Kitanga Nday
Apr 29 '17 at 17:44
@not2savvy I know what you mean, w3schools tend to be quite vague at times. But hey, they have a lot to do I guess.
– Kitanga Nday
Apr 29 '17 at 17:44
1
1
You're probably right. Here's my implementation, just for reference: Sketched box example (click toggle style to set light background)
– not2savvy
May 1 '17 at 12:16
You're probably right. Here's my implementation, just for reference: Sketched box example (click toggle style to set light background)
– not2savvy
May 1 '17 at 12:16
add a comment |
This article on hand-drawn borders gives a great example of achieving this effect on buttons using only CSS by using large elliptical rounded corners (through the CSS border-radius property). It probably won't work as well for large div elements.
Example adapted from the article:
button {
background:transparent;
padding:0.5rem 0.5rem;
margin:0 0.5rem;
font-size:1rem;
border-top-left-radius: 255px 15px;
border-top-right-radius: 15px 225px;
border-bottom-right-radius: 225px 15px;
border-bottom-left-radius:15px 255px;
}
button:hover{
box-shadow:2px 8px 4px -6px hsla(0,0%,0%,.3);
}
button.lined.thick{
border:solid 3px #41403E;
}
button.dotted.thick{
border:dotted 3px #41403E;
}
button.dashed.thick{
border:dashed 3px #41403E;
}
button.lined.thin{
border:solid 2px #41403E;
}
button.dotted.thin{
border:dotted 2px #41403E;
}
button.dashed.thin{
border:dashed 2px #41403E;
}<button class='lined thick'>Lined Thick</button>
<button class='dotted thick'>Dotted Thick</button>
<button class='dashed thick'>Dashed Thick</button>
<div> </div>
<button class='lined thin'>Lined Thin</button>
<button class='dotted thin'>Dotted Thin</button>
<button class='dashed thin'>Dashed Thin</button>add a comment |
This article on hand-drawn borders gives a great example of achieving this effect on buttons using only CSS by using large elliptical rounded corners (through the CSS border-radius property). It probably won't work as well for large div elements.
Example adapted from the article:
button {
background:transparent;
padding:0.5rem 0.5rem;
margin:0 0.5rem;
font-size:1rem;
border-top-left-radius: 255px 15px;
border-top-right-radius: 15px 225px;
border-bottom-right-radius: 225px 15px;
border-bottom-left-radius:15px 255px;
}
button:hover{
box-shadow:2px 8px 4px -6px hsla(0,0%,0%,.3);
}
button.lined.thick{
border:solid 3px #41403E;
}
button.dotted.thick{
border:dotted 3px #41403E;
}
button.dashed.thick{
border:dashed 3px #41403E;
}
button.lined.thin{
border:solid 2px #41403E;
}
button.dotted.thin{
border:dotted 2px #41403E;
}
button.dashed.thin{
border:dashed 2px #41403E;
}<button class='lined thick'>Lined Thick</button>
<button class='dotted thick'>Dotted Thick</button>
<button class='dashed thick'>Dashed Thick</button>
<div> </div>
<button class='lined thin'>Lined Thin</button>
<button class='dotted thin'>Dotted Thin</button>
<button class='dashed thin'>Dashed Thin</button>add a comment |
This article on hand-drawn borders gives a great example of achieving this effect on buttons using only CSS by using large elliptical rounded corners (through the CSS border-radius property). It probably won't work as well for large div elements.
Example adapted from the article:
button {
background:transparent;
padding:0.5rem 0.5rem;
margin:0 0.5rem;
font-size:1rem;
border-top-left-radius: 255px 15px;
border-top-right-radius: 15px 225px;
border-bottom-right-radius: 225px 15px;
border-bottom-left-radius:15px 255px;
}
button:hover{
box-shadow:2px 8px 4px -6px hsla(0,0%,0%,.3);
}
button.lined.thick{
border:solid 3px #41403E;
}
button.dotted.thick{
border:dotted 3px #41403E;
}
button.dashed.thick{
border:dashed 3px #41403E;
}
button.lined.thin{
border:solid 2px #41403E;
}
button.dotted.thin{
border:dotted 2px #41403E;
}
button.dashed.thin{
border:dashed 2px #41403E;
}<button class='lined thick'>Lined Thick</button>
<button class='dotted thick'>Dotted Thick</button>
<button class='dashed thick'>Dashed Thick</button>
<div> </div>
<button class='lined thin'>Lined Thin</button>
<button class='dotted thin'>Dotted Thin</button>
<button class='dashed thin'>Dashed Thin</button>This article on hand-drawn borders gives a great example of achieving this effect on buttons using only CSS by using large elliptical rounded corners (through the CSS border-radius property). It probably won't work as well for large div elements.
Example adapted from the article:
button {
background:transparent;
padding:0.5rem 0.5rem;
margin:0 0.5rem;
font-size:1rem;
border-top-left-radius: 255px 15px;
border-top-right-radius: 15px 225px;
border-bottom-right-radius: 225px 15px;
border-bottom-left-radius:15px 255px;
}
button:hover{
box-shadow:2px 8px 4px -6px hsla(0,0%,0%,.3);
}
button.lined.thick{
border:solid 3px #41403E;
}
button.dotted.thick{
border:dotted 3px #41403E;
}
button.dashed.thick{
border:dashed 3px #41403E;
}
button.lined.thin{
border:solid 2px #41403E;
}
button.dotted.thin{
border:dotted 2px #41403E;
}
button.dashed.thin{
border:dashed 2px #41403E;
}<button class='lined thick'>Lined Thick</button>
<button class='dotted thick'>Dotted Thick</button>
<button class='dashed thick'>Dashed Thick</button>
<div> </div>
<button class='lined thin'>Lined Thin</button>
<button class='dotted thin'>Dotted Thin</button>
<button class='dashed thin'>Dashed Thin</button>button {
background:transparent;
padding:0.5rem 0.5rem;
margin:0 0.5rem;
font-size:1rem;
border-top-left-radius: 255px 15px;
border-top-right-radius: 15px 225px;
border-bottom-right-radius: 225px 15px;
border-bottom-left-radius:15px 255px;
}
button:hover{
box-shadow:2px 8px 4px -6px hsla(0,0%,0%,.3);
}
button.lined.thick{
border:solid 3px #41403E;
}
button.dotted.thick{
border:dotted 3px #41403E;
}
button.dashed.thick{
border:dashed 3px #41403E;
}
button.lined.thin{
border:solid 2px #41403E;
}
button.dotted.thin{
border:dotted 2px #41403E;
}
button.dashed.thin{
border:dashed 2px #41403E;
}<button class='lined thick'>Lined Thick</button>
<button class='dotted thick'>Dotted Thick</button>
<button class='dashed thick'>Dashed Thick</button>
<div> </div>
<button class='lined thin'>Lined Thin</button>
<button class='dotted thin'>Dotted Thin</button>
<button class='dashed thin'>Dashed Thin</button>button {
background:transparent;
padding:0.5rem 0.5rem;
margin:0 0.5rem;
font-size:1rem;
border-top-left-radius: 255px 15px;
border-top-right-radius: 15px 225px;
border-bottom-right-radius: 225px 15px;
border-bottom-left-radius:15px 255px;
}
button:hover{
box-shadow:2px 8px 4px -6px hsla(0,0%,0%,.3);
}
button.lined.thick{
border:solid 3px #41403E;
}
button.dotted.thick{
border:dotted 3px #41403E;
}
button.dashed.thick{
border:dashed 3px #41403E;
}
button.lined.thin{
border:solid 2px #41403E;
}
button.dotted.thin{
border:dotted 2px #41403E;
}
button.dashed.thin{
border:dashed 2px #41403E;
}<button class='lined thick'>Lined Thick</button>
<button class='dotted thick'>Dotted Thick</button>
<button class='dashed thick'>Dashed Thick</button>
<div> </div>
<button class='lined thin'>Lined Thin</button>
<button class='dotted thin'>Dotted Thin</button>
<button class='dashed thin'>Dashed Thin</button>answered Nov 20 '18 at 13:21
SilveriSilveri
2,0692029
2,0692029
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%2f43694588%2fcan-i-use-css-to-distort-borders-so-they-look-like-sketched%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

I don't think so. I guess you could just use an image.
– Angel Politis
Apr 29 '17 at 10:45