I have created a page that is some very simple text images and a video. I have then put this content into a div(div innver), this div(div innver) has a white background. This Div(div innver) is then inside another div(div outer). Div(div outer) has a back ground colour of blue. for some reason div(div innver)'s background colour does not go the entire length of the page.
This is a link to a page that allows you to see my problem.
http://cssdeck.com/labs/bhppooft
What i am wanting is the white background to be the entire height of the page, not just the top.
Your inner div is absolutely positioned and has a fixed height of 100%. This results in a white box of exactly the same height as the viewport.
Check this one
I removed your absolute position of the div, it was causing the issue.
For the explanation, like #Paul said below :
Your inner div is absolutely positioned and has a fixed height of
100%. This results in a white box of exactly the same height as the
viewport.
EDIT after your comment :
You want the white div to be stick to the top and the bottom, see this fiddle
body { margin: 0;}
p:last-child { margin-bottom: 0; }
Be careful about margin and padding of your elements. The fix I've made works in the present case but couldn't work if you add others elements after the last p tag.
Also, make sure to close tags you are opening and respects the order of these (I didn't correct all tags in the JSFiddle)
Finally, you can use CSS stylesheets to clarify your HTML code :)
Just Remove both
Position: absolute;
Height:100%;
from the inner div then your problem will solved.
Wrong code
----------------xxx ------------
background-color: white;
bottom: 0;
font-size: 20px;
height: 100%;
left: 0;
margin: 0 auto;
position: absolute;
right: 0;
text-align: justify;
top: 0;
width: 80%;
z-index: -1;
---------------- xxxx -------------
Right code
----------------xxx ------------
background-color: white;
bottom: 0;
font-size: 20px;
left: 0;
margin: 0 auto;
right: 0;
text-align: justify;
top: 0;
width: 80%;
z-index: -1;
---------------- xxxx -------------
Related
I have a keyboard diagram to indicate to the user that they should be able to press a key to move from one cell of the CSS grid to another. The cells are set to the width and height of the browser. (The keypress does not function yet). Still, when I scroll up and down, the arrow key image remains, but when I scroll right, the right cells of the grid shove the image off the page? (It would also be nice to get rid of the negative margin on the body tag but that seems to be necessary when the image is a sticky element.
body {
margin: 0;
padding: 0;
margin-top: -102px;
}
.nav-legend {
position: sticky;
top: 10px;
padding-left: 10px;
}
https://codepen.io/russellbits/pen/eYjmWyg
Not sure if it gets the desired result, but it seems that position: fixed might be suitable for the use case.
Forked demo with modification: codepen
Example:
body {
margin: 0;
padding: 0;
}
.nav-legend {
position: fixed;
top: 10px;
left: 10px;
z-index: 999;
}
Hey Stackoverflow Community,
I have a simple lightbox script with a few images on the page, but it somehow doesn't work as it should. When I use position:fixed on then the overlay, then it is full and the image sticks to the top, but when I use position:absolute, then it is cut half way through page and the image is gone to the top.
There must be something really easy I am missing, right? Maybe my HTML structure is wrong?
The error can be found here live - http://kriskorn.eu/lightbox-error/
Thank you for all the help!
Kris
here are two issues
1) you are using padding-top: 700px; in .main p which force the images to go down the page . and with position absolute the images can never display with overlay. the overlay div will go up with scroll .here position:fixed can work .Reason is with position fixed the content will move upside and the overlay will stay on fixed position.
2) you should use opacity:0.* or any light color .you are using 0.95 which will not display the content below the div.
this should work please check
#overlay {
background-color: rgba(255,255,255,0.3);
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
text-align: center;
/* display: none; */
}
with position absolute it will not cover all the page.
this is surprising. Why you are using this ??
.main p {
padding-top: 700px;
}
this can also be an option.
.main p {
padding-top: 10px;
}
#overlay {
background-color: rgba(255,255,255,0.3);
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
/* display: none; */
text-align: center;
}
It seems that the answer I was looking for is, that you can't have position:absolute without some kind of JavaScript code. I used position:fixed after all, because that was already working for me.
I have the following testpage: ***
With a resolution of 1920x1080 the icon bar is located above the purple line.
On any other resolution it isn't anymore.
What is the best way to accomplish this (without javascript if possible)?
While I also would love to have the div element scale automatically, this is only the second problem. The main issue would be to have it always at the specific position.
As you can see % doesn't work.
#icons {
position: absolute;
right: 11%;
bottom: 12%;
width: auto;
height: auto;
z-index: 8;
max-width: 60%;
}
Do I have to work with "rem" or something along those lines (didn't work when I tried it either)? Is there even a way to do this?
Having an element in the top left corner obviously is very easy, since it will always stay the same even when resizing.
With this position there's also the problem of extra toolbars or similar - the position changes as soon as you hide the toolbar of the browser for example.
Any help appreciated!
Have you thought of trying:
#icons {
position: fixed;
right: 11%;
bottom: 12%;
width: auto;
height: auto;
z-index: 8;
max-width: 60%;
}
I use fixed for stuff I want to stay on the same spot, it usually "fixes" it to stay in its set place.
The text is absolutely positioned to the right and bottom edges of the window, so the solution is to position the background there too. Change top center to bottom right.
body {
font-family: Arial, "Myriad Pro";
font-size: 11px;
color: #ffffff;
background: #202020 url(img/body_back.jpg) no-repeat bottom right fixed;
background-size: cover;
}
I've been trying to figure out how to get my links working in layered divs
I have a big div containing two other divs:
main div with content and
a navigation div for my menu
The problem is that the main div is overlapping the navigation div wherein i want my links to be (ribbons) so that it looks like they are being pulled out when hovered. But they arent active links at all? my css is as follow:
.navigate {
width: 1020px;
height: 300px;
position: absolute;
right: 0;
left: 0;
margin-left: auto;
margin-right: auto;
top: 190px;
z-index: -1;
border: 1px solid red;}
and
.main {
background: url("../images/papir.png") no-repeat center; /* papir.png bredde=1020px */
margin-left: auto;
margin-right: auto;
margin-top: 150px;
margin-bottom: 7em;
width: 1020px; /* 1020px */
height: 752px; /* 752px */
z-index: 0;
border: 1px solid green; }
it's like the navigation div is behind something :$
When i change the z-index to 0 in the navigation div it works just fine except that the div is not behind the main div..
I've tried to fix it with
body {
position: relative;
z-index: 0; }
read somewhere that it should fix the problem - but not for me
Any ideas how to fix it?
Thanks in advance
Currently, you have the .navigate div z-index set to -1 so it is behind the .main div. Make it greater than the other divs so it's on top. E.g. z-index: 101;
Got it working!
Just added:
position: relative;
to the .main-div
When i change the z-index to 0 in the navigation div it works just fine except that the div is not behind the main div..
If I understand this correctly , there is no way to get a link to work if there is another div overlapping on top of the link , ex. If The nav div is under the main div the links on Nav div will not work
but..
if you want the div with the links on top - poistion them relative or absolute or fixed , and set the z-index to any number higher then the div you want behind
use negative margin for the div you want to over lay for example
.overlay-div{margin-top:-20px;}
I have a container div, within that div are other div's. In there I use jQuery .show() to show stuff.
#container {
position: absolute;
width: 600px;
left: 50%;
margin-left: -300px;
background-color: white;
height: 100%;
}
#content {
font-size: 15;
margin: 0 auto 0 auto;
width: 550px;
}
The content div grows longer than the container div, so the white background stops when I scroll down, leaving me with no white background there.
How can this be fixed?
http://jsfiddle.net/K6PAn/8/
I think this will be your answer, Adding padding to the top and bottom will always make the white shown.
Hope this helps, If it's not the correct answer, sorry! D:
Add an extra div at the end of the content with clear:both e.g.
<div style="clear:both"></div>
Dave