I want to build a simple web application with css, but I've been running into a problem. Here is the basic idea of what I need the structure to look like
I want element 2 and element 3 to be on the same line, but element 3 will not stay on the same line as element 2, and if I force it to stay on that line with inline-block, it doesn't take up the full width of the page.
How can I make the elements fit this way? I'd rather not use absolute positioning, but I don't see any way of making this work.
@font-face {
font-family: Assistant;
src: local("Assistant"), local("Assistant-Bold"), url(assets/Assistant.ttf);
font-weight: bold;
}
:root {
--m-body-bg-color: teal;
--m-font: Assistant;
--m-font-fg: whitesmoke;
--m-main-fg: crimson;
--m-gaps-px: 10px;
--m-container-radius: 10px;
}
body {
background-color: var(--m-body-bg-color);
position: relative;
width: 100%;
height: 100%;
}
.m-container {
position: relative;
margin: var(--m-gaps-px);
border-radius: var(--m-container-radius);
width: 100%;
height: 100%;
border: 2px solid var(--m-main-fg);
background-color: var(--m-main-fg);
display: inline-block;
}
.no-span {
width: fit-content !important;
}
#page-container {
height: 100%;
width: calc(100% - var(--m-gaps-px) * 4);
}
#page-container {
margin: var(--m-gaps-px);
}
<html lang="en-us">
<body>
<div id="page-container">
<div class="m-container" id="element-1">
</div>
<div class="m-container no-span" id="element-2">
theres some content here that i want to fit
</div>
<div class="m-container" id="element-3">
</div>
<div class="m-container" id="element-4">
</div>
</div>
</body>
</html>