I'm having a serious CSS challenge on a small project I'm building:
I have a <main> element which is set as flexbox of row. inside are 3 children:
:root {
--clr-light-text: #f2f2f2;
--clr-dark-text: #48484a;
--shadow-default: 0px 2px 8px rgba(0, 0, 0, 0.2);
--vid-container-h: 0px;
color: var(--clr-light-text);
font-family: 'Poppins', sans-serif;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
list-style: none;
text-decoration: none;
}
h1,
h2,
h3,
h4 {
font-weight: 400;
}
body {
background-color: var(--clr-dark-text);
text-align: center;
overflow-x: hidden;
scroll-behavior: smooth;
}
.glass {
background-image: linear-gradient( 135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0));
backdrop-filter: blur(5px);
border: 1px solid rgba(255, 255, 255, 0.15);
box-shadow: var(--shadow-default);
border-radius: 0.5rem;
}
main {
display: flex;
justify-content: center;
padding: 0 1rem;
gap: 2rem;
}
.main-container {
background-color: hsl(0, 0%, 75%);
padding-bottom: 10rem;
position: relative;
}
.weather-box {
width: clamp(13.5rem, 18%, 20rem);
display: flex;
flex-direction: column;
justify-content: space-evenly;
padding: 0 1em 1em 1em;
}
#weather-icon {
margin: -15% -10%;
}
.weather-details {
display: flex;
flex-direction: column;
justify-content: space-between;
}
#forecast,
#temp,
#humidity {
display: flex;
flex-direction: column;
align-items: center;
}
#temp {
margin-bottom: 1em;
font-weight: 200;
}
#temp-num {
font-size: 3em;
}
#humid {
font-size: 1.5em;
}
#humid-value {
font-size: 1.5em;
font-weight: 200;
}
#humid-value img {
max-width: 1em;
}
#forecast-desc {
font-size: 2.5em;
font-weight: 400;
}
.playlist-box {
width: clamp(13.5rem, 18%, 20rem);
display: flex;
align-items: center;
flex-direction: column;
padding: 1rem 0.5em;
flex-shrink: 0;
}
.playlist-box h3::after {
content: '';
width: 70%;
height: 1px;
background-color: rgba(255, 255, 255, 0.3);
border-radius: 100vmax;
display: block;
margin: 1em auto;
}
#playlist {
display: grid;
width: 100%;
padding: 1em;
overflow-y: scroll;
scroll-behavior: smooth;
}
#playlist li {
margin-bottom: 1rem;
width: 100%;
padding: 1rem;
border: 1px solid rgba(255, 255, 255, 0);
}
#playlist li:hover,
#playlist li:focus {
background-image: linear-gradient( 135deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0));
border: 1px solid rgba(255, 255, 255, 0.15);
box-shadow: var(--shadow-default);
border-radius: 0.5rem;
}
.song-title {
margin-bottom: 0.5em;
}
.vid-thumb {
width: 100%;
/* object-position: center;
object-fit: cover; */
}
.video-container {
align-self: flex-start;
padding: 1em;
}
#song-frame {
position: relative;
overflow: hidden;
width: 100%;
padding-top: 56.25%;
}
#song-frame iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<div class="main-container">
<main>
<aside class="weather-box glass">
<div id="forecast">
<img id="weather-icon" src="http://openweathermap.org/img/wn/02d#4x.png" alt="Weather Icon" />
<span id="forecast-desc">(--)</span>
</div>
<div class="weather-details">
<div id="temp">
<span id="temp-num">0°c</span>
<span id="feels-like">feels like 0°c</span>
</div>
<div id="humidity">
<span id="humid">Humidity</span>
<div id="humid-value">
<span id="humid-num">0%</span>
</div>
</div>
</div>
</aside>
<div class="video-container glass">
<div id="song-frame">
<iframe src="https://www.youtube.com/embed/oG08ukJPtR8" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" width="1024" height="576" frameborder="0"></iframe>
</div>
</div>
<aside class="playlist-box glass">
<h3>Browse Playlist:</h3>
<ul id="playlist">
<li>
<h4>Song Title</h4>
<img class="vid-thumb" src="https://i.ytimg.com/vi/ru0K8uYEZWw/hqdefault.jpg" alt="" />
</li>
<li>
<h4>Song Title</h4>
<img class="vid-thumb" src="https://i.ytimg.com/vi/pkCyfBibIbI/hqdefault.jpg" alt="" />
</li>
</ul>
</aside>
</main>
</div>
I applied to both <aside> elements to have a responsive width with the following width: clamp(13.5rem, 18%, 20rem). The div in the center uses the rest of the available width of the viewport. Generally, the layout kinda works.
The weather-container's clamp works just fine. The playlist-container though is able to shrink to less than 13.5rem (216px) and in some screen sizes I'm left with uneven containers in the sides.
The interesting part is that problem is somehow connected to the <img> thumbnails. The set width for them is 100%. If I cancel it out, the container behaves correctly but the thumbnails are cut off.
setting a fixed width value doesn't work.
setting a min-width to the element doesn't work.
setting flex-shrink: 0; to the element doesn't work.
messing with flex-basis also didn't work for me.
changing the <img> to a <div> with background-image instead produces the same result.
Would love to get over this problem, thank you.
Edit: I've produced a CodePen which recreates the problem: https://codepen.io/xandertem/pen/XWZLaVR
Try going to responsive mode and see the right section shrinking around <560px.
Adding flex-shrink: 0 to the aside (.playlist-box) solves the problem.
You should probably add the same rule to the other aside (.weather-box), even though you don't need it, just in case the type of content in that container ever changes. As you can see, images and videos make a difference.
For reasons I don't understand clamp in the width setting of flex just does not seem to work.
Also to automatically have the two asides with the height of the middle item you could use grid.
To get round what seems to be the clamp problem this snippet separates out the ranges by using min and max width media queries [when 18% is 13.5rem the overall width is 75rem and so on).
* {
box-sizing: border-box;
}
main {
display: grid;
grid-template-columns: 18% 1fr 18%;
width: 100vw;
}
#media screen and (max-width: 75rem) {
main {
grid-template-columns: 13.5rem 1fr 13.5rem;
}
}
#media screen and (min-width: 111.111rem) {
main {
grid-template-columns: 20rem 1fr 20rem;
}
}
main {
padding: 0 1rem;
gap: 2rem;
}
.weather-container {
display: flex;
flex-direction: column;
justify-content: space-evenly;
padding: 0 1em 1em 1em;
}
.video-container {
padding: 1em;
}
.playlist-container {
display: flex;
align-items: center;
flex-direction: column;
padding: 1rem 0.5em;
}
.vid-thumb {
width: 100%;
/* object-position: center;
object-fit: cover; */
}
<main>
<div class="weather-container">
...divs...
</div>
<div class="video-container">
<div>
<iframe>...</iframe>
</div>
</div>
<div class="playlist-container">
<h3>Browse Playlist:</h3>
<ul>
<li>
<h4>Song Title</h4>
<img class="vid-thumb" src="https://i.ytimg.com/vi/example.jpg" alt="">
</li>
<li>etc...</li>
</ul>
</div>
</main>
Related
I am working on a layout where I have two movie posters besides each other. There are two things that I can't get to work at the moment:
The overlaying text box should have the width of the poster and be located at the bottom of it (the bottom line of the text box should be at the same position as the bottom line of the poster).
The images should automatically resize so that the posters are always fully on the screen. At the moment, the bottom of the posters is not visible if the window becomes too small. They should also always keep their original aspect ratio (currently also not given).
The posters and their respective texts should always be centered on the screen.
This is how far I've got, however trying to solve any of the mentioned problems has created new ones so far.
JSFiddle
.layout {
width: 100%;
display: flex;
gap: 16px;
}
.film {
flex-grow: 1;
}
.poster {
width: 100%;
height: 100%;
max-width: 500px;
max-height: 700px;
}
.overlay {
color: white;
text-align: center;
font-size: 20px;
font-family: sans-serif;
background-color: rgb(0, 0, 0);
background-color: rgb(0, 0, 0, 0.5);
padding: 20px;
position: absolute;
bottom: 0;
width: 100%;
}
.remove {
text-align: center;
padding: 10px;
background-color: rgb(0, 0, 0);
background-color: rgb(0, 0, 0, 0.5);
color: white;
}
<section class="layout">
<div class="grow1">
<img class="poster" src="https://upload.wikimedia.org/wikipedia/commons/2/29/Marie_Kr%C3%B8yer_movie_poster.jpg">
<div class="overlay">Title<br><span class="year">2014</span></div>
<div class="remove">
Remove Film
</div>
</div>
<div class="grow1">
<img class="poster" src="https://upload.wikimedia.org/wikipedia/commons/2/29/Marie_Kr%C3%B8yer_movie_poster.jpg">
<div class="overlay">Title<br><span class="year">2015</span></div>
<div class="remove">
Remove Film
</div>
</div>
</section>
Desired result (roughly):
Here you are:
* {
box-sizing: border-box
}
html,
body {
width: 100vw;
height: 100vh;
margin: 0;
padding: 0
}
.layout {
width: 100%;
height: 100%;
display: flex;
justify-content: space-between;
gap: 16px;
padding: 16px;
}
.grow1 {
display: flex;
flex-direction: column;
justify-content: flex-end;
height: 100%;
max-width: 500px;
max-height: 700px;
position: relative;
}
.poster {
height: 100%;
align-self: center;
}
.overlay {
position: absolute;
right: 0;
left: 0;
bottom: 0;
color: white;
text-align: center;
font-size: 20px;
font-family: sans-serif;
background-color: rgba(0, 0, 0, .5);
padding: 20px 20px 10px;
}
.remove {
font-size: initial;
font-family: serif;
padding: 20px 0 0;
}
<section class="layout">
<div class="grow1">
<img class="poster" src="https://upload.wikimedia.org/wikipedia/commons/2/29/Marie_Kr%C3%B8yer_movie_poster.jpg">
<div class="overlay">Title<br><span class="year">2014</span>
<div class="remove">
Remove Film
</div>
</div>
</div>
<div class="grow1">
<img class="poster" src="https://upload.wikimedia.org/wikipedia/commons/2/29/Marie_Kr%C3%B8yer_movie_poster.jpg">
<div class="overlay">Title<br><span class="year">2015</span>
<div class="remove">
Remove Film
</div>
</div>
</div>
</section>
I'm practicing CSS/flexbox reproducing the login page of instagram but i'm facing a issue with horizontal alignment that i can't figure out what's wrong.
There's two major containers inside one big wrapper ("instagram-wraper" - each one get 50% of the width of that wraper).
Container 1 (left): "cellphone-img" that contain only a cellphone img
Container 2 (right): "account-info-container" that contain all the login inputs, subscribe, and so on.
The image on the left side work as intended, but what i'm trying to do is to align all the content in the account-info-container to the left with justify-content, essentially putting the image and the login containers side by side, but it doesn't work. What am i missing? (bet it's something simple...)
Thanks in advance.
PS: I didn't work on the responsiveness yet.
/* General settings */
* {
margin: 0;
padding: 0;
text-decoration: none;
box-sizing: border-box;
text-decoration: none;
font-family: "Roboto";
}
body {
width: 100%;
min-height: 100vh;
background-color: rgb(243, 243, 243);
font-size: 14px;
}
.flex-container {
display: flex;
/* max-width: 1200px; */
margin: auto;
width: 100%;
}
/* Wrapper img + wrapper login */
.instagram-wrapper {
align-items: center;
width: 60%;
height: 85vh;
}
/* Cellphone img container */
.cellphone-img {
display: flex;
align-items: center;
justify-content: flex-end;
width: 50%;
/* margin-left: 150px; */
}
.cellphone-img img {
height: 630px;
width: auto;
}
/* Login + subscribe + ap-downloads */
.account-info-container {
display: flex;
align-items: center;
flex-direction: column;
justify-content: flex-start;
width: 50%;
/* margin-right: 150px; */
}
/* Login wrapper */
.login-container {
flex-direction: column;
height: 420px;
width: 70%;
border: 1px solid rgba(var(--b6a, 219, 219, 219), 1);
background-color: #fff;
}
.insta-logo {
width: 100%;
display: flex;
justify-content: center;
padding-top: 55px;
padding-bottom: 35px;
}
/* Login inputs container */
.login {
align-items: center;
flex-direction: column;
}
.login input {
width: 85%;
height: 36px;
background-color: rgba(var(--b3f, 250, 250, 250), 1);
border: 1px solid rgba(var(--ca6, 219, 219, 219), 1);
border-radius: 3px;
font-size: 13px;
padding-left: 8px;
}
.input-login {
margin-bottom: 10px;
}
.input-password {
margin-bottom: 20px;
}
.login-btn {
width: 85%;
background-color: rgba(var(--d69, 0, 149, 246), 1);
border: 1px solid transparent;
border-radius: 4px;
color: #fff;
font-size: 14px;
padding: 5px 9px;
cursor: pointer;
font-weight: 600;
box-sizing: border-box;
}
.or-ruler {
width: 85%;
color: rgba(var(--f52, 142, 142, 142), 1);
display: flex;
justify-content: space-between;
align-items: center;
font-weight: 600;
margin-top: 20px;
}
.or-ruler::before {
content: "";
width: 120px;
height: 1px;
background-color: rgba(var(--ca6, 219, 219, 219), 1);
}
.or-ruler::after {
content: "";
width: 120px;
height: 1px;
background-color: rgba(var(--ca6, 219, 219, 219), 1);
}
.facebook-login-btn {
width: 85%;
color: #385185;
background-color: transparent;
border: none;
cursor: pointer;
margin: 30px auto;
display: flex;
justify-content: center;
}
.facebook-login-btn img {
width: 17px;
height: auto;
margin-right: 5px;
}
.forget-pass-link {
font-size: 12px;
cursor: pointer;
padding-bottom: 40px;
color: #00376b;
}
/* Subscribe container */
.subscribe {
align-items: center;
justify-content: center;
border: 1px solid rgba(var(--b6a, 219, 219, 219), 1);
background-color: #fff;
height: 70px;
width: 70%;
margin-top: 10px;
margin-bottom: 30px;
}
.subscribe p a {
font-weight: 600;
color: rgba(var(--d69, 0, 149, 246), 1);
}
/* Apps download wrapper */
.app-download {
align-items: center;
flex-direction: column;
width: 70%;
}
.app-imgs {
display: flex;
width: 100%;
justify-content: space-around;
}
.app-imgs img {
width: 170px;
height: auto;
padding-top: 30px;
}
/* Footer */
.footer-section {
max-width: 60%;
height: 100px;
margin: auto;
margin-bottom: 200px;
}
footer {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-size: 12px;
}
footer div {
margin: 8px auto;
}
footer a {
margin: auto 10px;
color: rgba(var(--f52, 142, 142, 142), 1);
text-decoration: none;
}
<div class="instagram-wrapper flex-container">
<div class="cellphone-img">
<img src="./images/instagram-celular2.png" alt="instagram cellphone" />
</div>
<div class="account-info-container">
<div class="login-container flex-container">
<div class="insta-logo">
<img src="./images/instagram-logo.png" alt="instagram-logo" />
</div>
<div class="login flex-container">
<input class="input-login" type="text" placeholder="Telefone, nome do usuário ou email" />
<input class="input-password" type="text" placeholder="Senha" />
<button class="login-btn">Entrar</button>
<div class="or-ruler">
<span> OU <span>
</div>
<button class="facebook-login-btn">
<span><img src="./images/fb-icon.png" alt="" /></span>
<span>Entrar com o Facebook</span>
</button>
<a class="forget-pass-link" href="">Esqueceu a senha?</a>
</div>
</div>
<div class="subscribe flex-container">
<p>Não tem uma conta? Cadastre-se</p>
</div>
<div class="app-download flex-container">
<p>Obtenha o aplicativo.</p>
<div class="app-imgs">
<img src="./images/apple-button.png" alt="appstore-img" />
<img src="./images/googleplay-button.png" alt="googleplay-img" />
</div>
</div>
</div>
</div>
<section class="footer-section">
<footer>
<div>
Meta
About
Blog
Jobs
Help
API
Privacy
Terms
Top Accounts
Hashtags
Locations
Instagram Lite
Contact Uploading & Non-Users
</div>
<div>
Dance
Food & Drink
Home & Garden
Music
Visual Arts
</div>
<div>
English
© 2022 Instagram from Meta
</div>
</footer>
</section>
If both of your items inside the container are each 50% width, they won't move horizontally—they're spanning across the entire container; there's no free space (and justify-content works by distributing free space).
Remove the width: 50% rule and work on each item individually (using width, margin and/or flex properties).
Also, the justify-content property doesn't take left and right values. They're invalid. Here are the values that work.
Finally, when you're ready to pin both items to the left, consider flex auto margins.
I'm trying to set the width of the scrollbar to 'thin' and 'none', neither of them are working. I have also tried using -webkit-
NOTE: I'VE SET THE OVERFLOW TO 'AUTO', IS IT THAT THE SCROLLBAR-WIDTH PROPERTY IS NOT WORKING?
The following is my HTML:
<div class="chat__chatting">
<div class="chat__scrollable-chat">
<div class="chat__chatting__header">
<div class="chat__chatting__header--img">
<img src="../../assets/person.png" />
</div>
<div class="chat__chatting__header--descr">
<div class="chat__chatting__header--name">Alexender</div>
<div class="chat__chatting__header--location">Birmingham, United Kingdom</div>
<div class="chat__chatting__header--age">Age 24</div>
</div>
</div>
<div class="chat__chatting__body">
<div class="chat__chatting__body--rcv-msg">
<div class="chat__chatting__body--rcv-msg--img">
<img src="../../assets/person.png" />
</div>
<div class="chat__chatting__body--rcv-msg---text">How are you?</div>
</div>
<div class="chat__chatting__body--sent-msg">
<div class="chat__chatting__body--sent-msg--img">
<img src="../../assets/person.png" />
</div>
<div class="chat__chatting__body--sent-msg---text">I'm fine</div>
</div>
</div>
</div>
<div class="chat__chatting__footer">
<textarea rows="1" class="chat__chatting__footer--textfield"></textarea>
<div class="chat__chatting__footer--send-btn">
<img src="../../assets/send.svg" />
</div>
</div>
</div>
And SCSS:
.chat{
&__scrollable-chat {
overflow-y: auto;
flex-grow: 1;
scrollbar-width: none;
}
&__chatting {
border-radius: 4px;
flex: 3;
height: 100%;
background-color: #fff;
display: flex;
flex-flow: column;
flex-grow: 3;
&__header {
display: flex;
flex-direction: row;
justify-content: center;
padding: 2rem 0;
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
&--img {
width: 11rem;
height: 11rem;
overflow: hidden;
border-radius: 50%;
overflow: hidden;
margin-right: 1.5rem;
img {
width: 100%;
height: 100%;
object-fit: cover;
}
}
&--descr {
padding-top: 1rem;
}
&--name {
font-size: 2.2rem;
color: $color-text;
padding-bottom: 0.6rem;
}
&--location,
&--age {
color: rgb(163, 163, 163);
font-size: 1.5rem;
display: block;
}
}
&__footer {
background-color: #f9f9f9;
display: flex;
flex-direction: row;
padding: 1rem 3rem;
position: sticky;
left: 0;
bottom: 0;
align-items: stretch;
&--textfield {
border: 1px solid rgba(0, 0, 0, 0.1);
resize: none;
font-size: 1.7rem;
font-family: "Lato", sans-serif;
padding: 7px 1.4rem;
color: $color-text;
outline: none;
width: 100%;
scrollbar-width: none;
border-radius: 15px;
max-width: 100%;
margin-right: 1.2rem;
}
&--send-btn {
width: 4rem;
height: 4rem;
img {
height: 100%;
width: 100%;
object-fit: fit;
}
}
}
}
}
Can someone please come up with a possible solution.
The scrollbar-width is too new for browser. Ref: Can I use scrollbar-width?
For other solution only for webkit browser (chrome, safari, and newer edge)
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
::-webkit-scrollbar-thumb {
background-color: darkgrey;
outline: 1px solid slategrey;
}
<textarea>ABCDE<br>ABCDE<br>ABCDE<br>ABCDE<br>ABCDE<br>ABCDE</textarea>
From the URL below, you can see the "scrollbar-width" is quite unpopular among browsers so that might be the reason why it's not working =>
https://caniuse.com/?search=scrollbar-width
You can use WebKit like
You have an element with scroll functionality.
set "::-webkit-scrollbar" on the same scroll element =>
.scroll-element::-webkit-scrollbar {
width: 4px;
height: 100%;
background-color: gray;
}
Keep in mind that this "background-color: gray" is for the scrollbar background and NOT for the actual scroller.
Let's make the actual scroller (the moving part) a different color, now use the "::webkit-scrollbar-thumb" =>
.scroll-element::-webkit-scrollbar-thumb {
background: #000;
}
I want to fit a picture into a website that still works when you scale it, but my picture is gigantic and I can't seem to make it fit. I tried to put a restriction on the wrapper div (here called "innpakning") on the picture itself, and the surrounding div. Nothing seems to work. And even if I could get it to work, that would defeat the purpose as I want it to scale to the website window. How do I make it fit the window?
I tried using
max-width: 100%;
max-height: 100%;
and it fixed the image, but not the spacing of the rest of the website. I end up with an enormous gap between .overskrift and .innhold.
<body>
<div class="innpakning">
<div class="overskrift">
<p id="text"> Hvaler </p>
</div>
<div class="innhold">
<div class="meny">
<div class="alt"> Info </div>
<div class="alt">Bilde </div>
<div class="alt"> Lyd </div>
<div class="alt"> Video </div>
</div>
<div class="faktisk">
<img src="css/media/hval.jpg" alt="">
</div>
</div>
</div>
</body>
innpakning{
margin: 20px;
padding-left: 10px;
padding-right: 10px;
display: grid;
grid-template-rows: 1fr 1fr;
}
.overskrift{
background-color: none;
color: black;
font-weight: bold;
}
.innhold {
background-color: #29648A;
}
.meny {
background-color: none;
display: grid;
margin: auto;
grid-template-columns: 1fr 1fr 1fr 1fr;
}
a {
text-decoration: none;
margin-left: 25px;
color: white;
}
.alt {
color: #FAFAFA;
text-decoration: none;
background-color: #25274D;
color: white;
padding: 10px;
margin: 2px;
}
.alt:hover {
background-color: #464866;
}
img {
margin-left: auto;
border: solid black;
max-width: 100%;
max-height: 100%;
}
.faktisk {
color: #DEDEDE;
padding: 15px;
margin: auto;
display: grid;
grid-template-columns: 1fr
}
#import url('https://fonts.googleapis.com/css?family=Asset');
#text {
font-family: Asset, cursive;
text-align: center;
font-size: 35px;
color: rgba(245, 246, 255, 0.96);
background-color: rgba(168, 168, 168, 0.11);
text-shadow: rgba(0, 0, 0, 0.99) 2px 2px 2px;
}
I suggest that you use the CSS unit type vw to set the max-width of the image, like so:
img {
margin-left: auto;
border: solid black;
max-height: 100%;
max-width: 100vw;
height: auto;
}
Read more at MDN: https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#Numbers_lengths_and_percentages
I am using flexbox to design this navigation bar
Eveything is working fine except for two problems:
The second div grows and shrinks as required but when the content gets too large the second div shifts to the left slightly.
I can't understand how to place a 4th div just below div 2(which should also grow and shrink like div 2) while maintaining all four in the same line as this is my first time with flexbox implementation. Ex:
The 4th div should be in the position of black mark and both the text and black mark should be vertically centered.
html,
body {
background-image: url("../images/theme1.png");
background-repeat: repeat;
}
.conversationHeader {
background-color: rgba(255, 255, 255, 0);
border: none;
min-height: 60px;
display: block;
}
.headerOnScroll {
background-color: rgba(255, 255, 255, 1);
box-shadow: 0 4px 6px -3px rgba(0, 0, 0, 0.2);
}
.horizontalLayout {
width: 100%;
margin: 0!important;
padding: 0 9px!important;
height: 68px;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
}
.conversationBackButton {
font-size: 24px;
width: 40px;
height: 40px;
padding: 8px!important;
margin-right: 16px;
color: #1D333E!important;
display: inline-flex;
}
.conversationDetails {
background-color: #cccccc;
font-family: robotoregular, 'sans-serif'!important;
font-size: 18px!important;
color: #546770;
flex-wrap: nowrap;
flex-grow: 1;
flex-shrink: 1;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
display: block;
}
.avatar {
min-width: 40px;
width: 40px;
height: 40px;
}
.composeMessageContainer {
background-color: white;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet"/>
<nav class="navbar navbar-fixed-top conversationHeader headerOnScroll">
<div class="container-fluid">
<div class="navbar-header horizontalLayout">
<a class="navbar-brand text-center conversationBackButton">
<span class="ionicons ion-android-arrow-back"></span>
</a>
<div class="conversationDetails">John Doe</div>
<img class="img-circle img-responsive avatar" src="images/dp.png">
</div>
</div>
</nav>
<div class="container-fluid navbar-fixed-bottom composeMessageContainer">
Text
</div>
If you add flex-shrink: 0 to the .conversationBackButton and .avatar it should work fine, as it will prevent them to shrink
.conversationBackButton {
font-size: 24px;
width: 40px;
height: 40px;
padding: 8px!important;
margin-right: 16px;
color: #1D333E!important;
display: inline-flex;
flex-shrink: 0; /* added */
}
.avatar {
min-width: 40px;
width: 40px;
height: 40px;
flex-shrink: 0; /* added */
}
To make the 4th div line up with the 2nd, move its markup the navbar-header horizontalLayout, remove navbar-fixed-bottom and change its CSS rule to this
.composeMessageContainer {
flex-basis: calc(100% - 56px - 40px);
margin-left: 56px;
background-color: red;
}
Update after a question edit
To make the 4th div line up with the 2nd, move its markup the conversationDetails, put the existing text in conversationDetails in its own div and remove navbar-fixed-bottom
.composeMessageContainer {
background-color: red;
}
Stack snipper
html,
body {
background-image: url("../images/theme1.png");
background-repeat: repeat;
}
body {
padding-top: 80px;
}
.conversationHeader {
background-color: rgba(255, 255, 255, 0);
border: none;
min-height: 60px;
display: block;
}
.headerOnScroll {
background-color: rgba(255, 255, 255, 1);
box-shadow: 0 4px 6px -3px rgba(0, 0, 0, 0.2);
}
.horizontalLayout {
width: 100%;
margin: 0!important;
padding: 0 9px!important;
height: 68px;
display: inline-flex;
flex-wrap: wrap;
align-items: center;
}
.conversationBackButton {
font-size: 24px;
width: 40px;
height: 40px;
padding: 8px!important;
margin-right: 16px;
color: #1D333E!important;
display: inline-flex;
flex-shrink: 0; /* added */
}
.conversationDetails {
background-color: #cccccc;
font-family: robotoregular, 'sans-serif'!important;
font-size: 18px!important;
color: #546770;
flex-wrap: nowrap;
flex-grow: 1;
flex-shrink: 1;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
display: block;
}
.avatar {
min-width: 40px;
width: 40px;
height: 40px;
flex-shrink: 0; /* added */
}
.composeMessageContainer {
background-color: red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet"/>
<nav class="navbar navbar-fixed-top conversationHeader headerOnScroll">
<div class="container-fluid">
<div class="navbar-header horizontalLayout">
<a class="navbar-brand text-center conversationBackButton">
<span class="ionicons ion-android-arrow-back"></span>
</a>
<div class="conversationDetails">
<div>John Doe</div>
<div class="composeMessageContainer">
Text
</div>
</div>
<img class="img-circle img-responsive avatar" src="images/dp.png">
</div>
</div>
</nav>