How to I push a fixed top div with 100% width, when another fixed right div is supposed to push it from the right side? I am making a collapsible mobile menu. It is toggled by a button on the top fixed div. Right now, the right fixed div overlaps the top fixed div menu button. I want this button to move left on the screen so that it is visible at all times. How do I accomplish this? I have not worked a whole lot with fixed elements in css. Thanks for any help.
Note: You will only see the menu and menu button I am talking about by resizing your browser window smaller. This menu is designed for a mobile layout.
Site:
http://dai1.designangler.com/
CSS:
#slide-menu {
margin-right: -250px;
right: 0;
top:0;
width: 250px;
background: #222;
position: fixed;
height: 100%;
overflow-y: auto;
z-index: 10001;
font-family: Roboto,sans-serif;
color: #fff;
font-weight: 100;
font-size: 1.5em;
}
#push{
/* This is the div that holds the menu button */
position: fixed;
top: 0;
padding: 0 1em;
background: #366982;
width:100%;
display:none;
z-index: 10000;
}
Screenshots to illustrate point:
menu closed: http://prntscr.com/2oaf82
menu open with button being overlapped: http://prntscr.com/2oafv4
You can't. Fixed is fixed. There are other ways though. Here's one:
In your JS that toggles the menu ($('#push, #close').click(function () {...}) also toggle a class on your body element called .menu-open
$('body').toggleClass('menu-open');
And update your css:
.menu-btn {
float: right;
margin-right: 2em;
}
.menu-open .menu-btn {
float: left;
margin-right: 0;
margin-left: 2em;
}
You cannot "push" a fixed element with any other because it is not relative to any other.
One way to do it taking another approach is to just change css right: 0 to left: 0 (or animate if you prefer) of the menu button container. A hint for this is that if you want to swap left and right properties of an element, you will have to give the other (being "removed", but you cannot really remove it) the auto value.
You can also have both elements displayed relative to each other in a container element and move that to achieve the effect of menu coming in from the right while the push button slide with it the left.
Related
I have a div with overflow hidden set up in order to cut an image:
The image on the right (the device) but it's affecting the popup on the left which MUST be there.
.hero {
position: relative;
padding: 32px 0 0;
min-height: 504px;
background: #D91A37 url(../images/flagscape-bg.jpg) 0 0/cover no-repeat;
overflow: hidden;
}
That popup already has z-index applied but it is not working due to the overflow hidden on that red background div.
So, is there a way to make that rule and not touching at all the popup on the left?
You should use position: absolute for your popup so that the properties defined on the parent are not inherited by the popup.
Your code should be something like:
.popup {
position: absolute:
top: 50px;
left: 20px;
z-index: 10;
}
And provide position: relative to a general parent above hero and popup.
I have a type of navigation that is contained within a 'pill' of sorts.
I need the pill (surrounding container) to automatically resize based on the amount of elements in the navigation.
I have the pill container centered on the page, so I don't think a float: left; or float: right; will work because it will override the margin: 0 auto;.
Here is a fiddle with an example of my issue: http://jsfiddle.net/TylerB/EU6XG/1/
How can I set this div element's width based on the amount of navigation items in the list?
Simply add display: table
DEMO http://jsfiddle.net/kevinPHPkevin/EU6XG/6/
.tabset-container {
margin: 0 auto;
position: relative;
top: 25px;
z-index: 1;
background: transparent;
text-align: center;
display:table;
}
Also add overflow: hidden to the tabs so then your rounded corners still show
.tabset {
overflow:hidden;
}
I was going in jQuery direction - fiddle (get the width and pass it trough .css())
+ display: inline-block on .tabset
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 white page with only a 500x250 textbox and an image. The page is fluid.
I'm trying to center the textbox at the center of a page, while having a picture fixed to the bottom left of the screen. I partially achieve this with the following css:
.bottom-right { /* used to fix the image to the bottom of the screen */
bottom: 0;
right: 0;
position: fixed;
}
#content {
margin-left: auto;
margin-right: auto;
margin-top: 50%;
width: 500px;
height: 250px;
position: relative;
}
When I vertically resize the window, the image covers the textbox. I would instead like the text to go up.
If I've understood your question correctly, you need to have the "textbox" always over the image that's fixed on the bottom-right corner.
See this working Fiddle Example!
CSS
#content {
width: 500px;
height: 250px;
position: absolute; /* this is the key */
z-index: 1; /* this is the key */
left: 50%;
top: 50%;
margin: -125px 0 0 -250px;
}
CSS position:absolute;
What this does is to place the element #content outside the normal document flow, thus not being affected by other elements or having impact on the layout of later siblings.
CSS z-index:1;
What this does is to move the element up on the document stack, thus placing it over others with a lower value (the default stack level is 0).
See the CSS absolute and fixed positioning - W3C Wiki for further details.
Two options I can think of:
Use CSS media queries and if the viewport is less than a certain height then change the textbox height or position so the image doesn't cover it.
Set a min-height around the parent div and once its less than a certain height, show a vertical scrollbar.
I have designed a website and am a little bit stumped right now.
If you view the website at:
http://www.noxinnovations.com/portfolio/charidimos/
If you change the size of the window you will notice the Navigation overlaps the logo/header.
Anyway to change this? What I want to do virtually is to make the window have a scroll bar appear if that is possible.
Any ideas?
Thank you :-D.
It's your width: 100%; in your #header element that's causing your strange overflow behavior. Place your #logo and #navigation elements inside of another div with a fixed height and width that sits inside of the #header, then give your #header the property overflow: hidden; and that should fix you right up.
If you want your navigation not to overlap, you can do the following
#navigation {
width: 500px;
height: 100px;
padding-top: 52px;
position: fixed; // CHANGE FROM RELATIVE TO FIXED
left: 770px; // ADD THIS BIT OF POSITIONING (ADJUST AS NECESSARY)
float: right; //REMOVE THIS FLOAT
text-align: center;
vertical-align: middle;
}