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

Position:fixed breaks font-size on mobile

I'm working on a site for mobile devices. Because differing resolutions and such, the idea is to keep font sizes at the browser default size (100%). This font-size: 100% works as planned (i.e. the text is readable in a mobile browser, not tiny) in…
preahkumpii
  • 1,301
  • 4
  • 21
  • 36
2
votes
2 answers

How to center images of unknown dimensions in floating boxes of fixed dimensions?

In each row I have three boxes (blue) of fixed dimensions (width: 299px, height: 307px) In every box there is an image (pink) of unknown dimensions. I know only max-width: 262px and max-height: 200px. Under the image there is some short two-three…
Nicpon
  • 95
  • 8
2
votes
2 answers

Expand relative positioned parent to height of absolute child

I intend to have a fluid height header, with a middle content section that expands to the available height and a footer anchored to the bottom. Like so:

Bacon ipsum dolor sit amet salami

ribs tongue…

Jun Wei Lee
  • 1,002
  • 11
  • 25
2
votes
1 answer

Max height not working with percentage when inside 'position: fixed'

I have a pop up dialog with a list of items in it. I am trying to give the list of items a max-height relative to the overall height of the screen. After some fiddling with the styles, it seems to me like it doesn't work when pop up dialog have…
Ben Laniado
  • 510
  • 6
  • 18
2
votes
1 answer

Fix DIV Geometry to Browser 100% Aside other Elements

http://jsbin.com/iGIToRuV/1/edit I'm working on a WYSIWYG website designer as an experiment for a variety of reasons. (The plan is to make this desktop and mobile friendly) One issue I'm having is getting the div#canvas to be 100% via width and…
Michael Schwartz
  • 8,153
  • 14
  • 81
  • 144
2
votes
1 answer

Override Google Maps places search box styling in jqm

I am trying to integrate Google maps Places search box into my jQuery Mobile App. I've created a search box with preferred styling in jQuery Mobile. I would like to use this search box instead of standard google search box. But for some reason my…
SpaceX
  • 2,814
  • 2
  • 42
  • 68
2
votes
1 answer

CSS Position fixed not fixing header to top

I am trying to fix the position of my header and cause a CSS transition on certain amount of scroll like this link I appended the position fixed for the header, in the header div, with the top:0 which apparently is a common mistake, unfortunately,…
Shouvik
  • 11,350
  • 16
  • 58
  • 89
2
votes
1 answer

How to get fluid box with absolute position while parent has a box-sizing of border-box?

I have two divs 'parent' and 'child'. Both boxes has a box-sizing property with value of border-box. Parent has fixed width and padding while I need child fluid width and absolute position. Child should be inside the parent div but instead its…
Imran
  • 1,094
  • 1
  • 21
  • 41
2
votes
2 answers

Stop a Sticky Div Script using jQuery Breakpoint

I am attempting to make a sidebar div stick (or become fixed) after scrolling down to it. When I scroll back up, it goes back to its position being relative. I use a plugin called (Breakpoint) which use to "break" the script, because my CSS media…
Mirume
  • 63
  • 2
  • 11
2
votes
2 answers

Safari - Content not displaying correctly, CSS position error?

In safari and some other browsers, my footer isnt sticking correctly. It looks to me like it must be something todo with either positioning or float. Would someone mind taking a look please? Have been pulling my hair out trying to solve…
atoms
  • 2,993
  • 2
  • 22
  • 43
2
votes
2 answers

Border are disaligned - Image not properly set (tables)

Hi there I have a problem with my table layout. I am trying to align "LEARN MORE" image under the blue text unfortunately its breaking the next element. SEE IMAGE: http://www.fileswap.com/dl/UDgc1YtJf1/
user2918348
2
votes
3 answers

css div parent border relative positioning

Have a parent div and child div. Using relative positioning in the child div element to place the contents of it. parent div element border is not enclosing the child div element. Tried overflow:hidden and padding options in parent div element…
Arav
  • 4,957
  • 23
  • 77
  • 123
2
votes
1 answer

Why is CSS positioning not behaving as expected with this table?

What I'd expect from the HTML below is that I'd see woo1 and woo2 overlapping while hiiii remains in its own cell away from the woos. However, everything runs together. Why? http://jsfiddle.net/T4Jgx/
oscilatingcretin
  • 10,457
  • 39
  • 119
  • 206
2
votes
4 answers

CSS center position:absolute background

I'm trying to keep the "sp" and "bg" divs centered at all times but I can't seem to do it. It is centered up until the width of the window exceeds the width of the image. After that, the image stays to the left of the page. All I want to change is…
robotturtle
  • 71
  • 3
  • 10
2
votes
3 answers

Fixed header and window resize

I have a fixed header with navigation menu on the site: #header_wrapper { height: 75px; background-color: #FD735B; z-index: 999; position: fixed; width: 100%; } #header_wrapper .control_wrapper { position: absolute; …
Tamara
  • 2,910
  • 6
  • 44
  • 73
1 2 3
99
100