positioning

Z-Index Relative or Absolute?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 18:45:52
I'm trying to find an answer to the following question: Is an element's z-index style its absolute stack order, or its stack order relative to its parent? For instance, suppose I have the following code: <div style="z-index:-100"> <div id="dHello" style="z-index:200">Hello World</div> </div> <div id="dDomination" style="z-index:100">I Dominate!</div> Which one will be in front - #dHello, or #dDomination? That's just for examples. I've tried this in multiple places and results seem to vary. I'm seeing if anyone knows of an authoritative source for settling: 1) What are the actual standards

How to horizontally center a floating element of a variable width?

微笑、不失礼 提交于 2019-11-26 15:17:35
问题 How to horizontally center a floating element of a variable width? Edit: I already have this working using a containing div for the floating element and specifying a width for the container (then use margin: 0 auto; for the container). I just wanted to know whether it can be done without using a containing element or at least without having to specify a width for the containing element. 回答1: Assuming the element which is floated and will be centered is a div with an id="content" ... <body>

Position an HTML element relative to its container using CSS

半世苍凉 提交于 2019-11-26 14:51:10
I'm trying to create a horizontal 100% stacked-bar graph using HTML and CSS. I'd like to create the bars using DIVs with background colors and percentage widths depending on the values I want to graph. I also want to have a grid lines to mark an arbitrary position along the graph. In my experimentation, I've already gotten the bars to stack horizontally by assigning the CSS property float: left . However, I'd like to avoid that, as it really seems to mess with the layout in confusing ways. Also, the grid lines don't seem to work very well when the bars are floated. I think that CSS positioning

Why aren&#39;t my absolutely-positioned elements located where I expect?

拜拜、爱过 提交于 2019-11-26 11:40:37
问题 I\'m just learning the positioning in CSS. Based on the article that I\'ve found useful, I\'d started to playing around. With the following code, I cannot understand why the absolute grey-box div is outside of it\'s relative parent. I expected that the grey-box will be on the top-left corner of the container. .container { background: lightblue; position: relative; } .box-orange { background: orange; height: 100px; width: 100px; position: relative; top: 100px; left: 100px; z-index: 2; } .box

jQuery: Difference between position() and offset()

耗尽温柔 提交于 2019-11-26 10:15:07
What is the difference between position() and offset() ? I tried to do the following in a click event: console.info($(this).position(), $(this).offset()); And they seem to return exactly the same... (The clicked element is within a table cell in a table) David Hedlund That depends on what context the element is in. position returns the position relative to the offset parent , and offset does the same relative to the document . Obviously, if the document is the offset parent, which is often the case, these will be identical. If you have a layout like this, however: <div style="position:

jQuery position DIV fixed at top on scroll

℡╲_俬逩灬. 提交于 2019-11-26 09:52:00
问题 I have a page that\'s fairly long and within the layout\'s menu, there\'s a flyout menu. I\'d like this flyout portion of the menu to show at the top of the page even when the user has scrolled the menu bar out of view. Here\'s the HTML for the menu <div id=\"task_flyout\"> <div id=\"info\">Compare up to 3 cards side-by-side. Click “Add to Compare” next to any card to get started…</div> <div id=\"card1\" class=\"card\"> <div class=\"cardimage\"></div><div class=\"cardname\"><a href=\"#\"></a>

CSS: fixed to bottom and centered

好久不见. 提交于 2019-11-26 09:18:42
问题 I need my footer to be fixed to the bottom of the page and to center it. The contents of the footer may change at all time so I can\'t just center it via margin-left: xxpx; margin-right: xxpx; The problem is that for some reason this doesn\'t work: #whatever { position: fixed; bottom: 0px; margin-right: auto; margin-left: auto; } I crawled the web and found nothing. I tried making a container div and nada. I tried other combinations and gurnisht. How can I make this happen? Thanks 回答1: You

What is the simplest jQuery way to have a &#39;position:fixed&#39; (always at top) div?

折月煮酒 提交于 2019-11-26 08:48:32
问题 I\'m relatively new to jQuery, but so far what I\'ve seen I like. What I want is for a div (or any element) to be across the top of the page as if \"position: fixed\" worked in every browser. I do not want something complicated. I do not want giant CSS hacks. I would prefer if just using jQuery (version 1.2.6) is good enough, but if I need jQuery-UI-core, then that\'s fine too. I\'ve tried $(\"#topBar\").scrollFollow(); <-- but that goes slow... I want something to appear really fixed. 回答1:

How do I center an SVG in a div?

不羁的心 提交于 2019-11-26 08:48:31
问题 I have an SVG that I am trying to center in a div. The div has a width or 900px. The SVG has a width of 400px. The SVG has its margin-left and margin-right set to auto. Doesn\'t work, it just acts as if the left margin is 0 (default). Anyone know my error? 回答1: SVG is inline by default. Add display: block to it and then margin: auto will work as expected. 回答2: Above answers did not work for me. Adding the attribute preserveAspectRatio="xMidYMin" to the <svg> tag did the trick though. The

Z-Index Relative or Absolute?

一曲冷凌霜 提交于 2019-11-26 06:33:47
问题 I\'m trying to find an answer to the following question: Is an element\'s z-index style its absolute stack order, or its stack order relative to its parent? For instance, suppose I have the following code: <div style=\"z-index:-100\"> <div id=\"dHello\" style=\"z-index:200\">Hello World</div> </div> <div id=\"dDomination\" style=\"z-index:100\">I Dominate!</div> Which one will be in front - #dHello, or #dDomination? That\'s just for examples. I\'ve tried this in multiple places and results