Overflow-x: auto, without hiding content - html

I've just made this section of images, where you're supposed to scroll horizontal to see the different images, and by the looks of the following screenshot, this is visually almost the result I wanted, with a few style changes to come
Section without overflow applied: the result I wanted
However, when I apply overflow-x: auto, in order to allow horizontal scrolling, the section cuts off the images on the right hand side:
Section with overflow applied: NOT the result I wanted
How can I make the section horizontal scrollable but without cutting the images off on the right?
It is basically a flexboxed section with three images so far:
<section class="projectSlideshow">
<img 1>
<img 2>
<img 3>
</section>
.projectSlideshow {
display: flex;
flex-direction: row;
height: 75vh;
margin-bottom: 2.25rem;
}

Oh well, sometimes, the solution you're looking for is so simple that you don't even think of it.
I solved it by putting the <section class="projectSlideshow></section> outside of my <div class="content"></div> (which contains the text above and below the slideshow, which is using padding to push in the text (the section was inside of it at first)), making them siblings to each other, instead of the section a child of the div.
Putting the <section> outside of <div> makes it possible for the slideshow to go from border to border (100% width). Then just adding the same margin-left to the first image as well as the same margin-right to the last image as the padding of the text gives the exact result I wanted.
A quick video of the result.

Related

CSS background does not fill all page properly when scrolled horizontally

So, I am new to HTML CSS and in progress in designing a website. I am designing a website which is similar to trello (https://trello.com). Where you can add cards, delete cards, etc.
I have this background problem where the background does not cover the whole page when I scrolled horizontally,
Here is the problem I have:
As you can see, the whole page looks okay, the background works properly. However, If I added more list, the background does not works properly.
Here, the background is white when I scrolled horizontally. It does not cover the whole page.
Here is my Html code:
<div class="container" id="amethystBackground2">
<!-- contents here -->
</div>
Here is my Css code:
#amethystBackground2
{
position: relative;
background-color:#9B59B6;
//This is needed to remove white space on top of page
margin: 30px 0 0 0;
//This is needed to for the background cover the whole page when scrolled verticallly
//(when you have too much cards, you need to scroll down)
min-height: 100vh;
min-width: 100vw;
//This is needed give space on top of page
margin: 50px 0 0 0;
}
I tried adding overflow-x: hidden and it is just not allowing me to scroll horizontally which is not helpful.
I also tried width:100% and 'height:100%', But it does not work.
Please help me, Thank you in advance.
The .container class of Bootstrap as a size in pixels, so it won't fit the whole page if you extend it.
First solution
Set your background-color to your body instead of your container div.
Just move background-color:#9B59B6 to
body {
background-color:#9B59B6;
}
Second solution
The "Bootstrapest way" would probably be using a container-fluid instead of a container, because it can expands to fill the available width.
<div class="container-fluid" id="amethystBackground2">
<!-- contents here -->
</div>
More about container-fluid here.
You have a class of container on there, if you are using bootstrap my advice would be to create your #amethystBackground2 div as an outer div so something like this:
<div id="amethystBackground2">
<div class="container">
</div>
</div>
Now set your widths/heights accordingly. If you use the overflow-x: hidden rule then you are telling the page that you don't wish to scroll horizontally so scroll bars will not be shown.

HTML/CSS: How to make a <div> containing an <img> tag inside a <section> responsive?

I'm making a website using fullPage.js, On the second page (or equivalently, second section) I want to achieve a very simple layout where I have a header fixed on top of the page displaying an image which should be responsive, or decreases in size as the window shrinks but stays at the top.
Currently, I'm wrapping the image to be displayed in a div. I then scale the div fullscreen using,
.post-header {
background: #22BDA0;
max-width: 100%;
height: auto;
}
The img tag inside of the div has a class header-image which I style as,
.post-header .header-image {
max-width: 100%;
height: auto;
margin: 0;
}
However, I'm not getting the desired result. There is a small space on top of the second page which I can't get rid of. You can see the website I'm making along with the source code HERE. Just scroll down to second page, or click Personal Details on the homepage.
Thanks a lot for the help!
What if you just give height:100%; to .section2-container? Will it solve your issue?
Remove display: table-cell; from .fp-tableCell and the padding disappears. Does this need to have display set to table-cell?
fullPage.js has an option: verticalCentered that can be set to false. This seems like a good solution, since the alternative means always trying to ensure that the content of the containing element is always 100%.

Cannot vertically center text in secondary NAV bar

On this one particular page, I have added a secondary menu (gray bar) under the primary menu (red bar) to have a few links that, when clicked, will scroll down the page to the correct area.
The secondary menu was, by default, much taller than I wanted it - so by adding a height: 40px; value, I was able to get it to the height I want. The page links, however, stubbornly did not adjust along with the height of the menu and thus, when viewed, they are obviously not in the correct place.
Is there a particular CSS value I can add to try and help this issue? I've tried adjust margin-top, padding-top, vertical-align, etc... and some of that adjusts the gray bar, but absolutely nothing has yet to adjust the text for me.
It doesn't help that I'm using a paid theme I bought rather than one I developed myself (in an attempt to make site management easier for someone else who takes over the site, this is more of a "drag-and-drop" template).
http://www.miltonpreserve.com/about/
It looks like you added the 40px height to the div with the #aboutmen id. However, some of the content nested in that div has padding that makes it taller than that. If you remove the padding from #menu-about-menu you should see the text become visible. Then (if needed) you can add 'vertical-align: middle' to the elements that you have nested in #menu-about-menu.
Here's a simplified version of what you have going on:
HTML
<div class="outer">
<div class="inner">
<div class="text">item one</div>
<div class="text">item two</div>
</div>
</div>
CSS
outer {
height: 40px;
background-color: yellow;
}
.inner {
padding: 30px;
}
This simplified example has the same problem you're experiencing. If you remove the padding from .inner, you'll see that the problem goes away. Here's a
jsfiddle with the same code.
Hope that helps!

allow scroll of div set behind another div

I have a iPad frame and want to have a larger image behind it (the page content) that scrolls down as you scroll. My css is more complicated then the example in the fiddle here https://jsfiddle.net/vk0jk37v/ but I cant seem to get even this to work.
in my real webpage I want to scroll down normally until I get to this image, then I want the scroll to effect the "page content" in this image. After I want to allow the user to continue scrolling normally after the "page content" of the image ends.
Edit: I have updated the fiddle and it rough but essentially what I am looking for except when I set the iPad frame to be on top of the image I am unable to get the content to scroll. the reason I need it under is to keep the image together when resizing the window with out covering the "fixed nav" or black side lines. Any thoughts on this? and thank you Felk for the hint in the right direction
Edit2: the image attached is the context in which I am applying this.
example html
<div class="container">
<img class="frame" src="http://s11.postimg.org/44ejhu0jn/ipad_frame_780.png" />
<div class="inner">
<img src="http://s11.postimg.org/xtwbnx937/ipad_content_660.png" />
</div>
</div>
example css
.container {
width: 70%;
position: relative;
}
.frame {
/* position: absolute; */
width: 100%;
z-index: 100;
}
.inner {
height: 558px;
overflow: scroll;
position: absolute;
top: 14%;
left: 38px;
}
.inner img {
width: 92%;
z-index: -100;
}
Ok. I was trying to fix your fiddle but at the end I have changed too much.
I will explain thought what I would do if I wanted to do your project. (hopefully if I have understood your question well enough).
First at all I would position the image of the ipad at the background with position:fixed and negative z-index. Now we have the image NOT moving at all as the position is placed relative to the window and not to any element. And also we have the first part of your content over the image and scrolling nicely.
Then we focus on the right flow of the html elements when scrolling so basically there will be more content under the first (and later under the image). I have added another div with red background to illustrate better the problem.
The html would look something like this:
<div class="container">
<div class="outer">
<img class="" src="http://s11.postimg.org/xtwbnx937/ipad_content_660.png"/>
</div>
<div class="frame">
<img class="ipad" src="http://s11.postimg.org/44ejhu0jn/ipad_frame_780.png" />
</div>
<div class="moreContent"></div>
</div>
Now we focus just on separate the top content from the bottom content. To do this we just add a big margin-bottom to the first content. Now when scrolling once you reach the end of the first content the image at the background will show then after the margin is over the last content will start flowing over the image (which is what you don't want)
basically we have this: FIDDLE1
Now it's just time to do a very simple jquery (it's always simple if I can use it). We just need to give some orders to the browser so I have used this:
$(window).scroll(function () {
if ($(window).scrollTop() > 1127) {
$(".frame").addClass('relative');
$(".outer").addClass('no-margin');
}
else {
$(".frame").removeClass('relative');
$(".outer").removeClass('no-margin');
}
});
basically I'm telling the browser that when the scroll is higher than 1227px (height) to add a class to frame and another to outer and if you scroll back to remove the classes.
Then The class I add to outer will just remove the big margin between first and last divs while the class add to frame will just make the container of the image relative so the flow of the html is normal and the image will keep scrolling down with the rest of elements.
Of course the 1227px I choose is based on the jsfiddle images you provided but in your future projects it won't be too hard to find the real height of your first content justinpecting it with chrome or simillar. same with the big margin I added.
The rest of changes was to make the sizes correct and center all elements in the window with at 600px width.
Here you have the final FIDDLE

How do I allow background elements to poke out past the content area of an HTML page?

I want to create an HTML/CSS layout for a page where there are multiple images that poke outside the content area of the page. The layout for the content area is fixed width and centered. I do not want scrollbars to appear if the user's window is as narrow as the content area.
The content area is a container div with a fixed width and margin: auto 0;
Ideas I've considered:
Use CSS 3 Multiple Backgrounds on the <body> tag. The background elements would have to be relative to the body, and wouldn't center with the content area.
Use negative margin or relatively positioned divs. This would make scrollbars appear if people had their browser width smaller than the width of the images that poke out past the content area.
I want the images to be kind of bonus content for people who have their browser windows fullscreen but not seem necessary.
Here's some example HTML/CSS that would simulate this example.
css:
#containerDiv {
width: 910px;
margin: 0 auto;
}
html:
<html>
<head>[...]</head>
<body>
<div id="containerDiv">
<header>HEADER</header>
<section id="contentArea">
<h1>Content</h1>
</section>
<footer>FOOTER</footer>
</div>
</body>
</html>
The scrollbar problem of your second idea could be simply fixed by setting:
body {
overflow-x: hidden;
}
The images would appear as much as they can according to the window size of the client; thus they would look like background, and only appear to those who have a higher screen resolution, without cluttering the lower-resolution people's screens.
Edit:
To get the images as you put in the example, use position: absolute and set their lefts, rights and tops as you see need. You could use a script to check whether the page hit a certain height; and when so, add the next picture you set.