- This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
Viewing 8 posts - 1 through 8 (of 8 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
I have a problem, it needs to center, the image vertically. How best to do it. Dimensions (height and width) my image in pixels, and that these were centered relative to the dimensions of the browser window.
Thank you in advance for your help!
Without more information it’s a little hard to give accurate advice.
@karlpcrowley This is something I learnt a few days ago: http://jsfiddle.net/joshnh/7SmcR/1/
@joshuanhibbert, that’s rather inefficient.
No, jquery or javascript. Dynamically vertically centers.
Always aim for no js.
@noahgelman Using the trigger method instead of writing the function a second time is what I would actually regard as very efficient.
Also, I never recommended using JavaScript.
Check this out!
http://jsfiddle.net/usc45/
@mauryaratan that’s horizontally aligned, not vertically…
@joshuanhibbert, I didn’t mean to say your javascript was inefficient, I just meant using javascript in this case if inefficient.
@karlpcrowley, yeah, that’s a more reduced solution than mine. I assumed he would have more stuff on the page- that’s why I put my image in a div. If it’s just the image, then yeah you don’t need it and what you put is better