EN
CSS - repeat image background horizontally only
0 points
In this article, we would like to show you how to repeat image background horizontally only using CSS.
Quick solution:
xxxxxxxxxx
1
body {
2
background-image: url("example-image.jpg");
3
background-repeat: repeat-x; /* required */
4
}
In this example, we repeat the background image horizontally (X-axis) using background-repeat
set to repeat-x;
.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<style>
5
6
body {
7
height: 300px;
8
background-image: url("https://dirask.com/static/bucket/1631891312626-6pQmxaWAb5--background-h200px.jpg");
9
10
/* required */
11
background-repeat: repeat-x;
12
}
13
14
div {
15
padding: 10px;
16
color: white;
17
}
18
19
</style>
20
</head>
21
<body>
22
<div>Example text...</div>
23
</body>
24
</html>