210 Many graphics APIs use relative positioning In such a sy
2.10 Many graphics APIs use relative positioning. In such a system, the API contains functions such as move_rel(x,y); line_rel(x,y); for drawing lines and polygons. The move_rel function moves an internal position, or cursor, to a new position; the line_rel function moves the cursor and defines a line segment between the old cursor position and the new position. What are the advantages and disadvantages of relative positioning as compared to the absolute positioning used in WebGL? Describe how you would add relative positioning to WebGL.
Also, can someone provide textbook solutions for Interactive Computer Graphics (7th Edition)? The book is missing almost every solution except chapter 1/question 1 from what I noticed. Thank you.
Solution
Relative. This type of positioning is probably the most confusing and misused. What it really means is \"relative to itself\". If you set position: relative; on an element but no other positioning attributes (top, left, bottom or right), it will no effect on it\'s positioning at all, it will be exactly as it would be if you left it as position: static; But if you DO give it some other positioning attribute, say, top: 10px;, it will shift it\'s position 10 pixels DOWN from where it would NORMALLY be. I\'m sure you can imagine, the ability to shift an element around based on it\'s regular position is pretty useful. I find myself using this to line up form elements many times that have a tendency to not want to line up how I want them to.
There are two other things that happen when you set position: relative; on an element that you should be aware of. One is that it introduces the ability to use z-index on that element, which doesn\'t really work with statically positioned elements. Even if you don\'t set a z-index value, this element will now appear on top of any other statically positioned element. You can\'t fight it by setting a higher z-index value on a statically positioned element. The other thing that happens is it limits the scope of absolutely positioned child elements. Any element that is a child of the relatively positioned element can be absolutely positioned within that block. This brings up some powerful opportunities which I talk about here.
Absolute. This is a very powerful type of positioning that allows you to literally place any page element exactly where you want it. You use the positioning attributes top, left bottom and right to set the location. Remember that these values will be relative to the next parent element with relative (or absolute) positioning. If there is no such parent, it will default all the way back up to the <html> element itself meaning it will be placed relatively to the page itself.
The trade-off, and most important thing to remember, about absolute positioning is that these elements are removed from the flow of elements on the page. An element with this type of positioning is not affected by other elements and it doesn\'t affect other elements. This is a serious thing to consider every time you use absolute positioning. It\'s overuse or improper use can limit the flexibility of your site.
I would suggest you wrap it all in a wrapper div which is centered and has position relative. Then you can position the controls absolute like this
