Sidebars 100% height as content and content 100% height as sidebars [duplicate] - css

This question already has answers here:
How do I achieve equal height divs (positioned side by side) with HTML / CSS ?
(11 answers)
Closed 7 years ago.
I'm building my website on Wordpress but stuck on one thing.
I want my sidebars, the left and right sidebar vertical in the same height as the content even the content inside the sidebar is shorter than the content in the midsection.
I also want the content in the midsection vertical in the same height as the content inside the sidebar if there is more content in the sidebar.
See website
See what I mean here

Add overflow: hidden; to the .containerdubbel div.
.containerdubbel {
position: relative;
padding: 0;
margin-left: auto;
margin-right: auto;
background: url(../Meerwoonruimte/images/achtergrond.png) repeat-y top left;
width: 990px;
min-height: 600px;
height: auto !important;
overflow: hidden;
}

Related

Center a position:fixed element with auto width [duplicate]

This question already has answers here:
Center aligning a fixed position div
(16 answers)
Closed 1 year ago.
I would like to make a position: fixed; header centered to the screen with a dynamic width and height. Right now, on desktop it is centered fine with this solution:
const Container = styled.div`
position: fixed;
left: 50%;
transform: translateX(-50%);
width: auto;
`;
I found that solution here. The problem I have is that if you enter my website, and make the window narrower, the header also gets smaller, and the menu items run out of space. I want to have width: auto; because I want the header to be just as wide as the menu and logo, even if I add or remove menu items, and I don't want to manually change the width every time I do that.
Can anyone think of a way to solve this?
Try to add this:
align-items: center;
justify-content: center;
I don't really know the reason for the width auto because that will just make the width the width of the child elements.

How to vertically center a div inside another div that does not have pre determined height? (has height auto) [duplicate]

This question already has answers here:
How can I vertically center a div element for all browsers using CSS?
(48 answers)
Closed 3 years ago.
So I already have done this once in this page: link to the website's page
In this page I was able to vertically center the text displayed on the image:
That column has 2 codes that make the text centered:
This one is added to the mother div
.academy-pc .one-third.mcb-wrap {
float: none;
display: table-cell;
position: relative;
}
and this one is on the child div that has the text:
.academy-pc .vertic-center {
position: absolute;
top: 50%;
transform: translate(0, -50%);
}
I've been trying to apply the same logic on this page but without success: page link
I wanted to vertically center the text in this image bellow but I just can't find a way.
Any help? thanks in advance
Into the .section_wrapper .mcb-section-inner add
display: flex;
justify-content: center;
align-items: center;
then everything inside will be vertically centered.
Of course you don't need to add padding: 200px 80px 0px 80px;

How to center a div vertically from a unknown dynamic height? [duplicate]

This question already has answers here:
How can I vertically center a div element for all browsers using CSS?
(48 answers)
Closed 5 years ago.
In my code there could be hundreds of elements depending on how much images is added to the pages, meaning the height of the page could be between 0 to 1000s or even more.
How would I center a overlay div in the middle of the page. The webpage is more or less trying to mimic Instagram, you can have hundreds of images but once you click on one of them the overlay is still set in the middle of the page.
This is the main div for the overlay of the images. this div works fine as long as the page is no longer than the view height of the page, if the height is too large that you have to scroll down, then it will mess with the position of the vertical. I know this problem is because im setting the bottom to 15% so it takes in consideration the entire height value. But I dont know how I can fix that.
.overlayImgContainer{
position: absolute;
height: 70%;
width: 120%;// (page is set to 960px this add a bit more room)
z-index: 1;
bottom: 15%;
left: -10%;
background-color: rgba(0,0,0,0.5);
overflow-x: hidden;
border-radius: 5px;
text-align: center;
}
You can use flexboxes for that.
CSS
.wrapper {
display: flex;
align-items: center;
justify-content: center;
}
HTML
<div class="wrapper">
<div>...</div>
</div>

Set div width using percentage without limiting to parent div width [duplicate]

This question already has answers here:
Make div inside parent 100% width of body, not parent div
(7 answers)
Closed 7 years ago.
Hello I have something like this in my HTML:
<div class="container">
<div class="image-slider"></div>
</div>
And here is my CSS:
.container {
max-width: 1133px;
margin-left: auto;
margin-right: auto;
}
I want to set the div width of .image-slider to 100% but here is the catch, instead of following the 100% width of the container which is only 1133px, I want it to follow the 100% width size of my body tag. Of course one solution is to put the image-slider out of the container but since this is a wordpress site, that kind of solution is not that easy to do in some complicated themes. Is there a way to make the .image-slider width 100% following the size of the body tag without putting it out of the container wrapper?
Positioning the div.image-slider absolute will take it out of the normal flow of the document, and its position will be relative to the first parent tag with a relative position.
body{
position: relative;
}
.image-slider{
position: absolute;
width: 100%;
}

Fixed width page layout, but adjustable with content

I want to upgrade my website's template.
I want the content to be in a fixed width centered div. This is not a problem and there are many examples on the web.
Since I have already content with text & tables, I want to make sure that the div will not cut the content of some pages.
I don't want to use Javascript to adjust the width.
Is there a way to do this with a div or should I use table instead?
Not getting your question right, centered as in vertically too? If you want it vertically centered than you need to use position: absolute; and if you want it horizontally centered you just need to use margin: auto;, as simple as that...
/* Totally center fixed width content */
.center {
position: absolute;
top: 50%;
left: 50%;
margin-top: /* Half of the total height of the container div */
margin-left: /* Half of the total width of the container div */
}
If you need the content horizontally centered, you need to use
.horizontal {
margin: auto;
}
Content won't be cropped unless and until you use a fixed width div and overflow: hidden; at the same time

Resources