I have a layout with a div which has rounded corners filling the whole screen (to get the look and feel of some member or credit card). So in a simplified way it's just
.card {
border: 1px solid black;
border-radius: 100px;
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 90vw;
height: 90vh;
}
<div class="card">
</div>
But when reducing the browser size the corners become to big obviously. If I use percent for the border roundness they get distorted. Is there any way to maintain the ratio between div and border-radius without a ton of Javascript?
You can use the vmax unit for the border radius which better suits the situation when the viewport/window orientation/format can both be portrait or landscape (see example in snippet below, adjust the value as needed).
Here's the description from mdn web docs
(from https://developer.mozilla.org/en-US/docs/Web/CSS/length)