Spaces Between Images
Problem:
I can’t center the Image or there are spaces between my images. If I delete the spacing in the code it goes away. Why is this?
Solution:
img { display:inline}
If the img has no display attribute defined, the default display is inline. This means that the image can be centered with text-align:center from an outer element. However, if there is a space between images, it may show a space when it is displayed. You can think of inline display as treating the image like text.
img {display:block}
If the img has a display:block attribute defined, the image cannot be centered with the text-align:center from an outer element. The image will take up the full line so that the elements before and after will appear on a different line. Because the image takes up the whole line, centering the image doesn’t have any effects. Spaces between images also do not show because the image fills the whole line.
A nice explanation of inline vs block can be found here: http://www.webdesignfromscratch.com/html-css/css-block-and-inline/
Image Optimization
Some great tools for optimizing images so that it downloads faster:
http://www.webdesignbooth.com/12-really-useful-image-optimization-tools-for-web-designers/
IE Back Bug
Apparently IE clears the form data by design. Mozilla and other browsers keep form data when the back button is pressed. I have not found a way around this besides setting cookies. This is different from getting javascript to run as that works ok.
http://www.scu.edu.au/flds/index.php/faq/249
Position Relative and Fade
These two hated with a hate Found only on the stage
– Lord Byron
Problem:
Having a position:relative on an element causes the jQuery fadeTo and fadeIn/fadeOut functions to not work in IE8 and possibly other IEs.
Solution:
Take out position: relative.
Onload Event When Back button is Pressed
Problem:
I have some ajax that pulls search results similar to how google images dynamically loads more images using javascript. So if the user clicks to see ‘page 2’ or ‘more’, javascript runs and fetches more images without the user leaving the page. If a user clicks on one of the results it will take them to another page. If the user then presses the Back button, the page that the user was on is lost because it’s as if they are visiting the page for the first time. A variable can be saved on the page to remember what page the user was on, but the onload javascript functions do not run when the back button is press.
Solution:
One of the solutions on stack overflow works like a charm. The following code lets the “onload” or jquery “ready” functions run when the back button is presssed.
history.navigationMode = 'compatible'; $(document).ready( function(){ alert('test'); });