Questions tagged [css-position]

The "position" property in CSS allows you to control the location of an element on the page by setting its value to static (the default setting), relative, absolute, fixed, or sticky.

The position property in CSS allows you to control the location of an element. Next to the inherit value, there are four specific values it can be set to:

  • static for positioning an element according to the "normal flow". This is the default and does not need to be set.

  • relative for positioning similar to static, albeit with a specific offset relative to its normal position

  • absolute for positioning elements along a coordinate system with respect to the element's "containing block"

  • fixed for positioning elements using a coordinate system that is fixed to the origin of the display surface (usually the origin of the client area of the enclosing browser window)

  • sticky for positioning an element as relative until a certain scrolling threshold has been reached, at which point the element is positioned as a fixed element.

CSS positioning often relies on additional layout properties (such as top, bottom, left, right, z-index, and clip) in order to achieve the desired outcome.

Example

/* static */
element {
  position: static;
}

/* relative */
element {
  position: relative;
  top: 65px; left: 65px;
}

/* absolute */
element {
  position: absolute;
  top: 40px; left: 40px;
}

/* sticky */
element {
  position: sticky;
  top: 20px;
}

References

  1. Positioning Schemes - W3C Spec
  2. CSS Position - MDN Link
6247 questions
2
votes
2 answers

In IE8, resetting clip via `clip: auto` cuts off children that are positioned outside an element

I'm using a clipping technique to hide content for sighted users but make it available to screen readers. It looks like this: .accessible-hide { position: absolute; clip: rect(1px 1px 1px 1px); } And when I want to show that item again, I can…
Paul d'Aoust
  • 3,019
  • 1
  • 25
  • 36
2
votes
2 answers

Absolute positioned div does not show outside the relative positioned div

Please look at the following example http://jsfiddle.net/GANeX/90/ I want to show my green colored div outside the wrapper. I cannot change the positioning of the wrapper div as inner-wrapper also holds some other content which may come out when we…
Jayant Varshney
  • 1,765
  • 1
  • 25
  • 42
2
votes
5 answers

Centering images with text-align

I am creating a simple site and I found out that I can center tags with text-align: center; but id does not work on block elements like
for example. Can someone explain to me how exactly the text-align works and if it's god practice to…
Beniamin Szabo
  • 1,909
  • 4
  • 17
  • 26
2
votes
3 answers

Negative Absolute Positioning, Removing Scrollbar

I am working on this site: http://waterwing.waterwing.ca/ The top right corner animation is perfect except for that it creates a horizontal scrollbar with the way it's positioned. It's absolutely positioned -120px top and right. I'm just wondering…
Wade D Ouellet
  • 681
  • 3
  • 21
  • 36
2
votes
0 answers

Is there a maximum or minimum top absolute position for SVG images in IE

I'm using absolute positioning to move a VERY large SVG img around inside another div element. I've set up a jsFiddle as a demo: http://jsfiddle.net/wEBnE/6 This works fine in all browsers except (you guessed it) IE. Click the button in the…
hofnarwillie
  • 3,563
  • 10
  • 49
  • 73
2
votes
2 answers

Is there a good javascript WYSIWYG tool that uses absolute positioning?

I'm building a site where users (with no knowledge of html/css) will custom-design simple static HTML pages. Years ago, I used a CMS that used absolute positioning with drag and drop for designing static pages, and it was a fantastically easy UI…
Travis
  • 4,018
  • 4
  • 37
  • 52
2
votes
2 answers

What is the difference between position relative and absolute (triangle)?

I'm little surprised while I was creating a triangle using :after pseudo class. Why position absolute works fine but not position relative. Look at the below code .test { position: relative; } .abs { position: absolute; left: 180px; …
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231
2
votes
2 answers

bPopup opens centre-aligned in one page and left-aligned in other

I'm using the bPopup plugin to open an iframe on two separate pages. I've written a small script which creates the iframe and "pops it up". This same script (exact URL etc) is referenced on both of my…
turbonerd
  • 1,234
  • 4
  • 27
  • 63
2
votes
1 answer

Border-Radius with position absolute images (no overlap)

I've got a inside and 's. My problem: the outer div got border-radius and overflow: hidden. The images are wider than it's parent . But overflow: hidden works well to hide the rest of the image. Only the border-radius works not on the images.…
Issis
  • 21
  • 1
  • 5
2
votes
2 answers

The best way for positioning header elements?

I have a div header with position:fixed which has logo, menu and search option inside. Logo is positioned on the left, menu in the middle and search on the right, logo and menu have relative positions, while search has position:absolute. Now, here…
Vladimir
  • 1,243
  • 5
  • 19
  • 23
2
votes
1 answer

Can I code absolute positioning elements of my website using Homestead sitebuilder?

I am creating a webpage with Homestead sitebuilder. http://www.homeinspection247.com/free-real-estate-agent-marketing.html I understand this may limit me as it doesn't seem to allow me to edit much of the html. My problem is different elements,…
2
votes
2 answers

Absolute positioning makes trouble with IE/Chrome

I have a gallery on my website. One way to switch the photo that's shown is to press the little images on the bottom of the gallery (as shown in the below photos). To position the little images I used absolute positioning and margins, as needed to…
OriShuss
  • 269
  • 2
  • 3
  • 14
2
votes
3 answers

CSS positioning involving a fixed width and the remaining space

I have a container with a width of 100% that contains 2 div, the first 1 has a fixed width of 50px and the second one needs to occupy all the remaining space (if I give it width: 100% it will obviously fall) Here's a sample simplified markup:
Jad Joubran
  • 2,511
  • 3
  • 31
  • 57
2
votes
1 answer

How to float 3 divs side by side irrespective of length?

So I want to float three divs side by side. Right now I have them with display: inline-block; and floating left, but when the window gets too small, the rightmost
is forced to be below the other two. Also I need it so that the rightmost and…
praks5432
  • 7,246
  • 32
  • 91
  • 156
2
votes
3 answers

How to align the h1 tag and the image tag on one line adjacently?

I have problems with trying to align the image and the h1 tag together on one line. I tried display: inline and inline-block they didn't work and only made the container of the two. I added the width to 100% on the section and still nothing. Float…
TheAmazingKnight
  • 2,442
  • 9
  • 49
  • 77
1 2 3
99
100