I am using the "vw" unit to define a font-size that is related to it's container width. This works rather ok, but I'm not entirely satisfied with the result. Let me explain...
The code below will generate a box around the container. Within the box I have a text with grey background.
When I show this in a fullscreen browser on my computer the text fills the width of the container. It looks like this:
However... When I resize the browser to approximately half the width of the screen it looks lik this:
The text size is reduced more than the container and the grey relative-text container. I may have misunderstood how the "vw" unit works. Can anyone explain how I should keep the relative font-size in a better way? My goal is that it should look similar in both a desktop and mobile environment.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- Custom styles -->
<style>
.container {
border-style: solid;
}
.relative-text {
font-family: helvetica, arial, sans-serif;
font-size: 2.5vmax;
background-color: #DDD;
}
</style>
</head>
<body>
<div class="container">
<div class="relative-text text-center"><== This text is resized when window is resized ==></div>
</div>
</body>
</html>