Problems with using flexbox for vertically aligning - html

I have a page-wide wrapping div that has flexbox alignment to center:
.app_container{
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
overflow-y: auto;
overflow-x: hidden;
padding: 10px;
}
In this wrapper, I have a menu that can vary in height as the user expands submenus. The problem is when the menu becomes vertically bigger than the window height. Some parts of the menu gets cut off at the top.
Image: https://imgur.com/a/x00tnoJ
One solution that I found was to simply get overflow: auto on the menu. But that causes the scroll bar to appear on the menu, not on the page wrapper. I want the scroll bar to be on the page wrapper.
Image: https://imgur.com/a/0eZM5Iq
Don't think it is relevant, but I use React.
Here is codepen: https://codepen.io/GuacomoleCyclone/pen/xxEoary
EDIT: I've stumbled upon a solution. I've added this and it solved all problems:
html, body{
display: grid;
}

If I understand correctly what your codepen is showing, the issue seems to be coming from setting the width and height on the html element. You want to change:
html, body {
width: 100%;
height: 100%;
padding: 0px;
margin: 0px;
}
to
html, body {
padding: 0px;
margin: 0px;
}
body {
width: 100%;
height: 100%;
}

Related

CSS div height & width not be applied

For some reason I am unable to apply height and width to div elements. I am using TailwindCSS and Nextjs.
My goal is to create slides to snap scroll vertically, but the height and width properties are removed in the browser.
Please any suggestions Im desperate.
This is my css for the container and each view within:
.snap-container {
overflow-y: scroll;
width: 100%;
height: 100vh;
display: flex;
flex-flow: column nowrap;
}
.snap-view {
height: 100vh;
width: 100%;
display: flex;
}
if you had
.snap-container {
overflow-y: scroll;
width: 100%;
height: 100vh;
display: flex;
flex-flow: column nowrap;
}
.snap-view {
height: 100vh;
width: 100%;
display: flex;
}
both your styles will be applied, even if on the picture you are showing only the .snap/view
but the height and width properties are removed in the browser.
this is because those are other properties around the code that are above the code you posted and they may have been overwritten by that, by being cascading
if you want the .h-screen and .w-full properties to apply regardless, you can put them direclty into the element, or trying putting them in the CSS below the .snap-container and .snap-view
try that, hoping I have helped

Navigation bar keeps hiding my body content

I was trying to build a web page and I started with some css I found online .
When I'm trying to add new div in the body it keeps appearing under the navbar.
I know it's related to position but I couldn't figure out a solution.
wrapper{
background: #171c24;
position: fixed;
width: 100%;
}
.wrapper nav{
position: relative;
display: flex;
max-width: calc(100% - 200px);
margin: 0 auto;
height: 70px;
align-items: center;
justify-content: space-between;
}
nav .content{
display: flex;
align-items: center;
}
https://jsfiddle.net/24d1keht/
Sorry , I couldn't post all the code here. Thank you.
Set the margin-top property of your body to the height of your navigation bar and then set the absolute position of your navigation bar to the very top of the page (so it isn't affected by the new margin), with the top property.
The CSS would look like this:
body {
margin-top: 0;
}
.wrapper {
top: 0;
}

Make two divs fill up entire page space while keeping vertical scroll

I have four divs, three of which are in the right position so far, but one div doesn't want to cooperate with me. Here's a diagram:
How would I go about making the blue div fill up the entire space of the red div?
This is what I want it to look like:
The red div has this css to make it have a scroll wheel when necessary:
.thread-container {
flex-grow: 1;
overflow-y: scroll;
position: relative;
}
The blue div has this css:
.thread-container .thread {
position: relative;
width: 100%;
min-height: 800px;
display: flex;
flex-direction: column;
justify-content: flex-end;
color: #b3b2ca;
background: #dcddf5;
}
I tested out adding height: 100%; to the blue div, but that made the div unable to scroll vertically.
If necessary, here is the css for the green div:
.message-input {
background: white;
color: #484d79;
box-sizing: border-box;
height: 10vh;
max-height: 65px;
}
By the way, I'm working with React here.
Thanks for reading!
~ Matthew

centering slides with react-slick

I'm trying to implement a react-slick carousel but I'm having trouble getting the image to vertically center. This problem is demonstrated here.
https://codesandbox.io/s/react-slick-playground-o7dhn
Here is the problems
Images are not centered:
Flexbox property does not work (the red div is a flexbox with justify-content: center;
align-items: center;)
margin:auto only works for horizontal alignment (which I shouldn't have to set if I'm using flexbox)
I can not get rid of the top margin (even with padding:0px on the div and margin-top:0px on the image) As a consequence, any image with the height of 400px or more gets shifted and cut off (div has the height of 400px)
How do I fix it.
img {
margin: auto;
height: 200px;
width: 200px;
}
.slick-slide > div {
display: grid;
place-items: center;
width: 80%;
margin-top: 50px;
margin: auto;
height: 500px;
padding: 0px;
background: red;
}
This is working right now. I just changed display flex to grid, and made place-items centered

HTML/CSS - Scrollable section does not fit to the page.

I have a web application, which I did not develop myself, but am tasked with cleaning up a few things that are no longer working.
There is one issue that I am not really able to figure out why it is happening.
The web application is split into two panels. However, the second panel which is scrollable does not reach the bottom of the page, when a user scrolls all the way down.
Also by zooming out (ctrl -) we get a blank area at the bottom, although the panel can continue scrolling.
Id like to have this panel, scroll as if it was the full page.
Ive put a quick static copy up on fiddle at.
https://jsfiddle.net/brianz820/qmzw8923/
The section in question I believe is.
<div id="house-estimates-scroll-panel">
<div id="house-estimates-listing"></div>
</div>
div#house-estimates-scroll-panel {
position: relative;
/*display: inline-block;*/
margin: 0;
padding: 0;
height: 1200px;
/*height: 100%;*/
/*width: 100%;*/
overflow-y: visible ;
overflow-x:hidden;
background-image: linear-gradient(to right, #f3f3f3 , #bbb);
background-size: 15px 20px;
background-position: right;
background-repeat: repeat-y;
}
div#house-estimates-listing {
margin: 0;
padding: 0;
height: 90000px;
/*width: 320px;*/
/*width: 960px;*/
}
Ive added the full HTML and CSS sections to the fiddle.
You could try making the wrapper into a display:flex container by adding these rules (some look weird because of specificity issues)
body {
height: 100%;
}
div#wrapper {
flex-direction: column;
height: 100%;
display:flex;
overflow: hidden;
}
div#house-estimates-panel {
display:flex;
overflow: hidden;
}
div#house-estimates-scroll-panel{
height: auto;
flex: 1 auto;
}
div#house-estimates-listing {
height: auto;
}
demo: https://jsfiddle.net/gw35wc4c/1/show/
source (my css is at the bottom): https://jsfiddle.net/gw35wc4c/1/