I am trying to build a digital restaurant menu… I designed it like a popup, so it sits in a fixed container on top of a gray transparent overlay. Since there are more dishes than fitting into this container, I wanted the container to be scrollable, which I achieved with overflow-y: scroll. At this point
it still worked perfectly.
But on the bottom of the container I wanted fixed footer with a white-to-transparent gradient containing a button to close the whole menu popup. Since the stuff that I thought of didn't work, I placed it inside of another container on top of the popup… Now it looks as I wanted it, but the menu in the background is not scrollable anymore.
I guess there must be another way… How can I place the container with the close button on the bottom of the menu container while still being able to scroll?
Here is a jsFiddle…
Your container for the button at the bottom is overlaying the scrollable container, so when you try and scroll the text, you're actually trying to scroll inside of the bottom-container as its over the top. I have made a JS fiddle, with an example of what you're trying to achieve.
https://jsfiddle.net/8ydb2h2m/
body {
background: #ccc;
}
.box {
width: 100%;
height: 100%;
max-width: 80%;
max-height: 80%;
left: 0;
top: 0;
margin: 5% 10%;
position: fixed;
background: #fff;
overflow: hidden;
}
.top-section {
height: 20%;
background: #c00;
}
.scroll-section {
height: 70%;
overflow-y: scroll;
}
.bottom-section {
height: 10%;
}
.button {
background: #c00;
height: 30px;
width: 100px;
margin: auto;
text-align: center;
}
Related
i want the name in the middle of the page to scroll up as i scroll down, i made the bottom div climb on top of the image with the fixed position but that somehow included the name and subtitle as well. i dont want that.
i have currently 2 container divs
and one div that got the texts inside it
here is the css code:
/thats the first fixed div with the image/
#intro {
display: 100%;
position: fixed;
z-index: -99;
background-image: url('images/la.jpeg');
top: 0;
height: 500px;
width: 100%;
}
/this second div is for the h1 and p
its a child of the intro div with the image. /
.infirst {
display: inline-block;
position: absolute;
margin: 250px 0 0 580px;
}
/and last is the div climbing up on top of both of them /
.about-me {
background-color: #000000;
width: auto;
height: 1000px;
position: relative;
z-index: 1000;
margin-top: 100%;
}
picture of the site
I'm trying to achieve an example as shown on this site. Click on the "Projects" button on the top right corner below the main menu to reveal the container I am interested in replicating.
When stretching the webpage from left to right and top to bottom, that project pop up is responsive and the padding around the page keeps the same value. I was able to get my width responsive but cannot figure out how to get the same thing for my height since I don't have a specific value for my height. I want the box in my site to be responsive on bigger computer screens than what I am using right now (15" macbook pro) because right now it only takes up half the screen on a bigger monitor.
Here's my code:
nav {
/* max-width: 1266px; */
width: 87.92%;
margin: 50px auto 23px auto;
height: 40px;
background-color: pink;
}
.content {
/* width: 1266px; */
width: 87.92%;
height: 540px;
margin: 0px auto 0px auto;
background-color: aquamarine;
}
<nav>
</nav>
<div class="content">
</div>
Try here.
I want there to have 50px padding at the top and bottom of the webpage even as you shrink the page top to bottom. Right now my nav has a margin-top of 50px, but ideally, I'd like the entire page to have a padding of 50px at the top and bottom. I just don't know how to go about this and I can't seem to find an answer anywhere!
Thank you!!
You can use calc() for this:
height: calc(100vh - 163px);
100vh = total height of screen
163px = 113px + 50px
(113px is the height of your nav with margins and 50px is the distance to the page bottom)
There are several ways to do. One way is to use fixed or absolute positioning. The page http://kokopako.fr/profile fixes the position. Notice that the body in that page no longer scrolls when the Projects menu is open. This is something you need to enable using JavaScript.
So, imagine originally the body is tall and only the navigation is visible at the top:
body {
height: 1900px;
}
nav {
height: 40px;
background-color: pink;
width: 87.92%;
margin: 50px auto 23px auto;
}
.content {
background-color: aquamarine;
display: none;
}
Then when you click no "Projects" button, you would add an extra class, say projects_visible to body so that it doesn't scroll.
.projects_visible {
overflow: hidden;
}
Then the navigation and the content would display automatically with fixed position.
.projects_visible nav {
position: absolute;
top: 50px;
right: 50px;
left: 50px;
margin: 0;
}
.projects_visible .content {
display: block;
position: absolute;
bottom: 50px;
top: 123px;
right: 50px;
left: 50px;
}
I have a very large table with a position:fixed header that stays at the top of the page when you scroll down the page.
I've been trying to enhance this by putting the table inside of a reasonably-sized width container with overflow:auto but the fixed container extends outside the div.
Here is a simplified JS fiddle
The problem with overflow stems from your position fixed property for the header element, furthermore the horizontal scroll on the container (unless intentional) should be fixed by adding the overflow-x: hidden property to your container element.
.container {
width: 400px;
height: 400px;
background: #ccc;
overflow-x: hidden;
}
.header {
width: 600px;
height: 100px;
background: #ddd;
}
.content {
width: 600px;
height: 600px;
background: #eee;
}
Let me know if this is not the answer you're looking for, we can discuss further.
I am designing a web page with a little toggle menu icon for navigation purposes.
My problem is that whenever the window is resized under the width of the main container (.story, which only has max-width defined), the menu icon overlaps the content.
Instead, I would like the icon to block on the right border of my container.
currently, the code for positionning my nav icon:
nav {
position: fixed;
top: 100px;
right: 100px;
}
and the container:
.story {
padding-top: 50px;
margin: 0 auto;
height: 1000px;
max-width: 1000px;
text-align: justify;
}
Here is a jsfiddle to illustrate my problem.
and here is an example of a website where they made it work
Thanks for taking a look at it.
Per my understanding, position:fixed will overlap data.
A simple way can be reducing width of story div.
nav css
nav { position: fixed; top: 20px; right: 20px; }
story css
.story {
padding: 50px 0;
margin: 0 auto;
height: 1000px;
max-width: 400px;
text-align: justify;}
I am trying to get a full width background or image behind floated items within a max-width container. The page will be responsive so I can't fix the height of the .item objects nor be sure how many will be shown on each row.
I'd like to have a background or image running full length of the window aligned to a position in the .item div. I can use a very long div or image offset to the left without any issue but the right side makes the browser scroll which I don't want.
.bg {
background: red;
bottom: 0;
height: 30px;
left: -1000px;
position: absolute;
width: 2000px;
z-index: 0;
}
Fiddle here: http://jsfiddle.net/K8uAh/4/
The red banner is my background, see how it runs off to the right.
Ideally I would do this just using CSS, I know if I have to go the JavaScript route it all gets a bit clunky on the window resize.
You can use the .container. If you don't want the container to extend the entire width you need to remove overflow: hidden; and add it to an additional wrapper div.
body {
width: 100%;
margin: 0;
}
.container {
overflow: hidden;
}
Hi I tried on your fiddle and altered the width and the left attribute to have percentage instead of px as if we are dealing with px then it will be hard to make it responsive.
Code:
.bg {
background: red;
bottom: 0;
height: 30px;
position: absolute;
width: 125%;
left:-16%;
z-index: 0;
}
Fiddle: http://jsfiddle.net/K8uAh/1/
You can use a clear-fix div at the end of .item.
body {
width: 100%
}
.container{
background: red; /* Change your color here */
margin: 0 auto;
width: 100%
overflow: hidden;
}
.item{
background: #999;
float: left;
margin: 10px 5%;
position: relative;
width: 40%;
}
Fiddle
First : your fiddle css is incorrect :
body {
width: 100%;
}
} /*<- extra closing braces here is ruining your layout*/
see what i mean
second : to have a full width bg use:
background: #ccc url('http://hdwallpaperia.com/wp-content/uploads/2013/11/Flower-Vintage-Background-640x400.jpg');
background-size :100% 100%;
container class should be :
.container {
background: #ccc url('http://hdwallpaperia.com/wp-content/uploads/2013/11/Flower-Vintage-Background-640x400.jpg');
background-size :100% 100%;
margin: 0 auto;
max-width: 300px;
overflow: hidden;
}
working demo