fluid layout and maintaining child element relative position and size - html

I am attempting to make a fluid layout for an existing site. By changing the widths to percentages I have created an issue with my navigation where, when the screen size is adjusted, the child elements of the navigation also adjust. I'd like them to remain constant in relation to the parent element so that when the screen is adjusted, the nav adjusts while the children just scale to fit without changing position.
js fiddle here: http://jsfiddle.net/Xa99f/
Notice that when you adjust the screen width the child elements shrink/expand and even collapse under one another when the width is made very small.
Put another way, how would I create a fluid layout where I make the main element in question fluid (in this case nav) while keeping all descendants scaled relative to that without losing desired position?

Related

CSS flex layout with an image height relative to visible page and with maximum relative width

I'm trying to achieve the below layout.
I have a region that, ideally, fills most of browser's height; I want it all within view, with a potential minimum height. On the left is an image that stretches to fill the area, with the aspect retained, but will not go beyond a maximum width. On the right is a div that takes up the remaining space.
I can't figure out the HTML and CSS flex-box styles that would achieve it.

CSS Adaptive Styling - Add scrolling to a sidebar without a defined height

I'm creating a basic web app which contains a sidebar that is sized vertically by how many elements are in it.
I want the web-app to have adaptive sizing, so will work on any size device.
When the user shrinks the viewport vertically and some of the elements within the sidebar overflow the viewport, I want the sidebar to shrink not overflowing the viewport, and allow scrolling of its contents.
The sidebar is not a predefined height (eg. 50% or 700px), as it is determined by how many elements are within it (could be 3, could be 30).
The image below is the best way I can visualise what I am looking to do:
CSS example
White: is the viewport
Light Blue: is the sidebar
Dark Blue: is the elements inside sidebar
Grey: is the scrollbar
I can get this to work when the sidebar is a predefined height by using overflow: auto, but cannot get this to work when I do not define the height of the sidebar, and leave it to the child elements to determine its height.
Any help at all would be greatly appreciated!
If i can understand true, you can use calc() function in your css.
eg:
If you show 5 element on viewport(height), you can use this code for element style:
height: calc(100vh/5)
this code means: Divide the entire apparent height by 5.
eg: https://jsfiddle.net/uniak/rgzf9nmy/

Form page fixed height and responsiveness

I have the following layout I need to solve
I understand that the whole idea of the responsive design is to leave the height to adjust to the content, but for this particular work the customer wants it this way no matter how I have to figure it out but I'm struggling hard to achieve it
In my mockup I have a 100% height and weight body, and then a container taking 85% height of the body size.
Inside that container there are the following elements:
A Top div container with the company logo
A Progress bar with a step number
A small div with some instructions for the current step
A Div containing the form elements that the user has to fill
A bottom div with 2 navigation buttons
The content should be always visible no matter the device used (see image below)
Number 4. has a inner scrollbar with overflow-y because that content will change
In order to do this i set heights in percentage (%) for each div within the container, however I need some padding for the elements, but when the browser resizes or the device changes height and width the elements overlap each other
I don't want to rely on a bunch of media queries to fix this. I wonder if anyone can find an approach or some reference for this since i can't seem to find it
Thanks
If you don't want to use many media queries, I think you should use Jquery (or Javascript) like this:
Fixed height of all div except FORM CONTENT (include padding, margin, border with box-sizing: border-box). You can use some media queries for best style.
Use Jquery to calculate height of FORM CONTENT (this is scrollable content)
Example:
$('#form-content').height($(window).height() - X);
// With X = total height of other divs includes margin, padding, border
Call this script in $(document).ready(...) and $(window).resize(...)
Hope this help.

What is the css positioning style that keeps all elements positioned the same when the window is resized?

My html page has some text, a search bar, a results pane, a navigation bar, and several other elements which i want to stay in the same position relative to each other.
My thoughts were to make absolutely positioned divs inside a relatively positioned container div, and then give them all min/max pixel values.
If i gave them min/max pixel values they wouldnt change size/positioning when the window was resized, correct?
But if i did this then wouldnt they not fit on monitors with smaller screens?
Forgive any inaccuracies in my statements, im still in the learning process.
If you set the height and width to a percent, then set a min-height and min-width, the divs will flex to the size of the parent div (which is dependent on the size of the parent window). The problem with that solution is that with smaller screen size windows, the absolute positioning for the elements won't allow you them to nudge down if the content of an individual div needs to wrap. You might be able to position your internal divs using the default browser settings and adjusting the margin values, and use float: left or float: right to position elements that need to be adjacent.

Parent height smaller than child, why?

I'm trying to stretch an image vertically in a parent container of my site (not the full body), it is the div with the id "imagen-fondo"
I have tried either backstretch plugin and also just css background-image with background-size to do it.
But the problem in both cases is that the calculated height of the parent container is smaller that the immediate child height, so, the background image looks smaller than the content itself.
How can I make it to be the same height as his immediate child or at least bigger?
You can see the live demo here:
http://50.21.181.12:3001/plantillas/mba
UPDATE:
I think the problem is that div#imagen-fondo is getting the height of the window and not of his content, that is the reason that when the screen is big, the problem doesn't happen, but when the height of the window is smaller than the content it happens, you can check it with this two screenshots, just as you start scrolling vertical the background image ends:
Something with overflows?
UPDATE 2:
For now I introduced some javascript to make it work,
Getting the footer offset position and stretching the height of the ".backstretch" div to that height.
But, if you resize the window to make the vertical scroll bar appear and inspect the page, you can still see that the parent container "#imagen-fondo" (from where backstretch should automatically get his height) is still getting the height of the visible viewport and not from the content itself.
If anyone finds a better way to do it CSS only will use that approach instead of this dirty one.
Clear floats in parent div using clear: both;
Or use clearfix on parent div.
For now I introduced some javascript to make it work,
Reading the footer position and stretching the height of the ".backstretch" div to that height.
But, if you resize the window to make the vertical scroll bar appear and inspect the page, you can still see that the parent container "#imagen-fondo" (from where backstretch should automatically get his height) is still getting the height of the visible viewport and not from the content itself.
If anyone finds a better way to do it CSS only will use that approach instead of this dirty one.