100% ширина блока до следующего блока
Доброго времени суток.
Есть несколько страниц, на одной странице две колоны (контент + меню), на других одна (контент). Есть "настройки" которые должны располагаться по центру блока "контента". На странице с "меню" ширина вычисляется с помощью calc из 100% и "пустого блока" с шириной меню, но на других страницах этого блока нет. Собственно интересует как можно расположить 2 блока, левый из которых будет всегда 100%. Чтобы без проблем убирать из кода правый блок. Возможно есть иное решение?
Спасибо.
<div class="container">
<div class="block element-1">100% - 50px</div>
<div class="block element-2">50px</div>
</div>
<div class="container">
<div class="block element-3">100%</div>
</div>
<div class="container">
<div class="block element-3">100%</div>
<div class="block element-4">50px</div>
</div>
html {
box-sizing: border-box;
}
:root {
background-color: #373150;
font-size: 16px;
font-weight: 400;
text-rendering: geometricPrecision;
line-height: 1.4;
text-decoration-skip: ink;
font-family: -apple-system-headline, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
*, *:before, *:after {
box-sizing: inherit;
}
body {
margin:0;
padding:0;
}
.block {
display:inline-block;
background-color:#EF6174;
color:white;
font-size:0.8em;
text-align:center;
line-height:4em;
}
.container {
display:block;
max-width:900px;
margin:0 auto 20px auto;
}
.element-1 {
float:left;
height:50px;
width: calc( 100% - 50px );
}
.element-2 {
float:left;
width: 40px;
height:50px;
margin-left:10px;
}
.element-3 {
float:left;
height:50px;
width: 100%;
}
.element-4 {
float:left;
width: 40px;
height:50px;
margin-left:10px;
}
Ответы (1 шт):
Автор решения: Roman
→ Ссылка
Есть. В .container ставите display: flex;
.container {
display: flex;
...
}