css-position

CSS transform: translate moves postion:fixed inner Div

风格不统一 提交于 2019-11-30 14:50:09
问题 The following example shows a div inside a div. The inner div is position: fixed; When I add transform: translate(0px, 0px); to the outer div, the inner div will no longer behave as fixed Link to the example: http://dabblet.com/gist/1723937 So, does translate actually change the viewport? Can anyone help me to keep the inner div fixed using css, when the outer div has a translate style? Thank you, Felix 回答1: Here is an article on it: http://meyerweb.com/eric/thoughts/2011/09/12/un-fixing

Absolute positioning and its parent element

有些话、适合烂在心里 提交于 2019-11-30 14:08:43
问题 I've always heard that when you use absolute positioning that the element you want to act as its parent needs to have a position of relative . I was trying to build a CSS dropdown menu and I was struggling to get the dropdown menu items stretch beyond the width of the main menu item when I had its parent element I wanted it to use set as relative ; the text in the drop down menu items would just wrap. So I looked around at other example menus to see how they did it and one I found wasn't even

Absolutely positioned div on right causing scrollbar when the left doesn't

时光怂恿深爱的人放手 提交于 2019-11-30 13:49:58
问题 I'm trying to "flank" a centered div with some design elements that are absolutely positioned outside the main div's width. I'm getting a scroll bar due to the element on the right, but not the element on the left (IE6/7/8, Chrome, Firefox). How can I get rid of that horizontal scrollbar? <html> <head> <style type="text/css"> html, body { height: 100%; width: 100%; margin: 0; } body { text-align: center; } .wrapper { margin: 0 auto; position: relative; width: 960px; z-index: 0; } .main {

Set width of fixed positioned div relative to his parent having max-width

本秂侑毒 提交于 2019-11-30 12:37:33
Is there any solution without JS? html <div class="wrapper"> <div class="fix"></div> </div> css .wrapper { max-width: 500px; border: 1px solid red; height: 5500px; position: relative; } .fix { width: inherit; height: 20px; position:fixed; background: black; } I cant add any other styles for .wrapper except width: 100%; . I try with width: inherit but it doesn't work for me because of I have parent div with only max-width. source Here is JsFiddle Demo A position:fixed element is not relative to its parent anymore. It respects only the viewport's boudaries. MDN Definition : fixed Do not leave

How to fix Absolute Positioning In IE8?

久未见 提交于 2019-11-30 11:24:17
问题 In every browser I've used, except ie8, an absolutely positioned element can be positioned according to the closest parent with relative positioning. The below code shows two divs inside a table. The top div has position: relative, however, the nested, absolutely positioned element does not respect its boundaries (in ie8, it gets positioned at the bottom of the page instead of the bottom of the parent div). Does anybody know a fix for this? <style> #top { position: relative; background-color:

CSS positioning to fill container: width vs. left/right?

最后都变了- 提交于 2019-11-30 11:12:00
Considering: For elements that are absolutely positioned inside a relatively positioned container. If you want the element to fill the width of the container. The element is also bottom-aligned. Is it best for maximum browser compatibility to set a width in pixels for the element, or simply use left and right ? Any common bugs to watch out for with either method? Clearly, using left: 0; and right: 0; would make the code more manageable in cases where the image's width or padding were to change, but are there any downsides where width: 300px would be favorable instead? Historically we learnt to

Absolute positioning and its parent element

北城余情 提交于 2019-11-30 09:29:47
I've always heard that when you use absolute positioning that the element you want to act as its parent needs to have a position of relative . I was trying to build a CSS dropdown menu and I was struggling to get the dropdown menu items stretch beyond the width of the main menu item when I had its parent element I wanted it to use set as relative ; the text in the drop down menu items would just wrap. So I looked around at other example menus to see how they did it and one I found wasn't even using any parent elements with a position of relative even though they were using absolute positioning

Header and footer with fixed position while content is scrollable?

落爺英雄遲暮 提交于 2019-11-30 08:47:52
I'm trying to make a website where header and footer have fixed position while content scrolls in the middle. <header style="position:fixed"></header> <div id="content">some content</div> <footer style="position:fixed"></footer> I created what I thought would work but it doesn't. Here's jsFiddle with the whole thing. As you can see, part of content is hidden under the footer and beyond (I can't see 'HELLOWEEN' in the end). What must I change to fix it? Thanx The easiest fix for this is to add padding equivalent to the height of your static header and footer: #content { width: 80%; margin: 0

Absolutely positioned div on right causing scrollbar when the left doesn't

霸气de小男生 提交于 2019-11-30 08:34:26
I'm trying to "flank" a centered div with some design elements that are absolutely positioned outside the main div's width. I'm getting a scroll bar due to the element on the right, but not the element on the left (IE6/7/8, Chrome, Firefox). How can I get rid of that horizontal scrollbar? <html> <head> <style type="text/css"> html, body { height: 100%; width: 100%; margin: 0; } body { text-align: center; } .wrapper { margin: 0 auto; position: relative; width: 960px; z-index: 0; } .main { background: #900; height: 700px; } .right, .left { position: absolute; height: 100px; width: 100px; }

fixed position div freezes on page (iPad)

半世苍凉 提交于 2019-11-30 08:33:53
问题 I have an asp.net web site I am building to be supported on ipad. When I focus on an input element and the keyboard pops up, the position fixed header div(which normally scrolls along with the page) will pop up the page a distance equivalent to the amount the keyboard takes up and freeze there for the duration of the input process. Once the keyboard is dropped back down, the div snaps back into place and behaves normally again. I am testing on iOS5 so position: fixed should be supported. Is