EN
CSS - set element max width
0 points
In this article, we would like to show you how to set element max width using CSS.
Quick solution:
xxxxxxxxxx
1
.element {
2
max-width: 100px;
3
}
In this example, we use max-width
CSS property to set element maximum width to 200px
. If the width
property percentage value will be more than 200px
, the max-width
property will prevent the element from expanding horizontally.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<style>
5
6
div.element {
7
width: 90%;
8
max-width: 200px;
9
background: orange;
10
}
11
12
</style>
13
</head>
14
<body>
15
<div class="element">Example text inside ...</div>
16
</body>
17
</html>