Questions tagged [position]

Position refers to the location of an element relative to its container, typically on the horizontal and vertical axes.

In computing, position closely relates to the geometrical definition of a position or position vector, also known as location vector or radius vector, which is a Euclidean vector that represents the position of a point P in space in relation to an arbitrary reference origin O. Usually denoted x, r or s, it corresponds to the displacement from O to P.

In simplified terms, position is used in reference to the location of a 'child' entity within a two-dimensional or three-dimensional space, the boundaries of which are referred to as the 'container' or 'parent'.

9210 questions
156
votes
10 answers

CSS3 box-sizing: margin-box; Why not?

Why don't we have box-sizing: margin-box;? Usually when we put box-sizing: border-box; in our style sheets we really mean the former. Example: Let's say I have a 2 column page layout. Both columns have a width of 50%, but they look kind of ugly…
Web_Designer
  • 72,308
  • 93
  • 206
  • 262
154
votes
8 answers

Position: absolute and parent height?

I have some containers and their children are only absolute / relatively positioned. How to set containers height so their children will be inside of them? Here's the code: HTML
Foo
154
votes
5 answers

Float right and position absolute doesn't work together

I want a div to be always at the right of its parent div, so I use float:right. It works. But I also want it to not affect other content when inserted, so I use position:absolute. Now float:right doesn't work, my div is always at the left of its…
trbaphong
  • 1,583
  • 2
  • 11
  • 9
137
votes
11 answers

How to find out element position in slice?

How does one determine the position of an element present in slice? I need something like the following: type intSlice []int func (slice intSlice) pos(value int) int { for p, v := range slice { if (v == value) { return p …
OCyril
  • 2,875
  • 4
  • 20
  • 11
135
votes
5 answers

Center a 'div' in the middle of the screen, even when the page is scrolled up or down?

I have in my page a button which when clicked displays a div (popup style) in the middle of my screen. I am using the following CSS to center the div in the middle of the screen: .PopupPanel { border: solid 1px black; position: absolute; …
tanya
  • 2,925
  • 7
  • 32
  • 49
127
votes
3 answers

position div to bottom of containing div

How can i position a div to the bottom of the containing div?
nagy.zsolt.hun
  • 6,292
  • 12
  • 56
  • 95
124
votes
9 answers

Sticky sidebar: stick to bottom when scrolling down, top when scrolling up

I have been looking for some time now for a solution to my sticky sidebar problem. I have a specific idea of how I would like it to act; effectively, I would like it to stick to the bottom as you scroll down, and then as soon as you scroll back up I…
andbamnan
  • 1,285
  • 2
  • 11
  • 8
119
votes
6 answers

Using jquery to get element's position relative to viewport

What's the proper way to get the position of an element on the page relative to the viewport (rather than the document). jQuery.offset function seemed promising: Get the current coordinates of the first element, or set the coordinates of every…
DA.
  • 39,848
  • 49
  • 150
  • 213
117
votes
3 answers

c# datatable insert column at position 0

does anyone know the best way to insert a column in a datatable at position 0?
Grant
  • 11,138
  • 32
  • 94
  • 140
114
votes
5 answers

Using Position Relative/Absolute within a TD?

I have the following code: Contents of table cell, variable height, could be more than 60px;
Notice …
Jason Axelrod
  • 7,155
  • 10
  • 50
  • 78
113
votes
7 answers

How to get mouse position in jQuery without mouse-events?

I would like to get current mouse position but I don't want to use: $(document).bind('mousemove',function(e){ $("#log").text("e.pageX: " + e.pageX + ", e.pageY: " + e.pageY); }); because I just need to get the position and process the…
MartyIX
  • 27,828
  • 29
  • 136
  • 207
109
votes
11 answers

Event to detect when position:sticky is triggered

I'm using the new position: sticky (info) to create an iOS-like list of content. It's working well and far superior than the previous JavaScript alternative (example) however as far as I know no event is fired when it's triggered, which means I…
Alec Rust
  • 10,532
  • 12
  • 48
  • 63
107
votes
9 answers

CSS absolute position won't work with margin-left:auto margin-right: auto

Say you have the following CSS applied to a div tag .divtagABS { position: absolute; margin-left: auto; margin-right: auto; } the margin-left and margin-right does not take effect but if you have relative, it works…
user1118019
  • 3,819
  • 8
  • 40
  • 46
95
votes
2 answers

Check if element is visible on screen

Possible Duplicate: jQuery - Check if element is visible after scroling I'm trying to determine if an element is visible on screen. In order to to this, I'm trying to find the element's vertical position using offsetTop, but the value returned is…
Robert
  • 951
  • 1
  • 7
  • 3
92
votes
6 answers

Difference between position:sticky and position:fixed?

The documentation was pretty hard to understand since I am new to CSS. So can anyone please explain the actual difference between position:sticky and position:fixed? I would also appreciate an example. I have gone through…
user2791037