I would like to know if it is possible to generate diagonal lines in css or svg to cover a div which will allow the background colour of the div to show through. Something like the following.
If anyone has an example that would be helpful.
I would like to know if it is possible to generate diagonal lines in css or svg to cover a div which will allow the background colour of the div to show through. Something like the following.
If anyone has an example that would be helpful.
You can try:
HTML:
<div class="deg45 stripes">TEST</div>
CSS3:
.stripes {
height: 250px;
width: 375px;
-webkit-background-size: 50px 50px;
-moz-background-size: 50px 50px;
background-size: 50px 50px;
}
.deg45 {
background-color: white;
background-image: -webkit-gradient(linear, 0 0, 100% 100%, color-stop(.25, gray), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, gray), color-stop(.75, gray), color-stop(.75, transparent), to(transparent));
background-image: -webkit-linear-gradient(-45deg, gray 25%, transparent 25%, transparent 50%, gray 50%, gray 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, gray 25%, transparent 25%, transparent 50%, gray 50%, gray 75%, transparent 75%, transparent);
background-image: -ms-linear-gradient(-45deg, gray 25%, transparent 25%, transparent 50%, gray 50%, gray 75%, transparent 75%, transparent);
background-image: -o-linear-gradient(-45deg, gray 25%, transparent 25%, transparent 50%, gray 50%, gray 75%, transparent 75%, transparent);
background-image: linear-gradient(-45deg, gray 25%, transparent 25%, transparent 50%, gray 50%, gray 75%, transparent 75%, transparent);
}
Where you can customize it to your needs as:
-45deg
is the amount og the angle you want the stripes to have and gray
the color of them. Also with background-size
you can define the size of them
You can use base64 data as a png image. For example:
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAQElEQVQYV2NkIAKckTrzn5GQOpAik2cmjHgVwhSBDMOpEFkRToXoirAqxKYIQyEuRSgK8SmCKySkCKyQGEUghQD+Nia8BIDCEQAAAABJRU5ErkJggg==);
Yes i did it on a btn.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<button style=" background-size: 10px 10px;
background: repeating-linear-gradient(45deg,#606dbc,#606dbc 10px,#465298 10px,#465298 20px);
height: 600%;"type="button" class="btn btn-default btn-lg">Large Default Button</button>
</div>
</body>
</html>
There's a tool called stripe generator which solely purposes to create striped images.
http://www.stripegenerator.com/index.php
When done, tweak as required using the following css:
.stripes {
background-image: url(/assets/images/stripe.png);
background-position: 4px 0;
background-size: 16px;
}