Jump to content
MakeWebGames

CSS Error


jcvenom

Recommended Posts

I'm doing work for a client and for some reason my css looks weird. When minimized by pressing CTRL + (-) it decreases in the top left corner of the page, rather than decreasing in the center unfortunately I can't show the code nor the url due to people copying my work, I can only show the url to some people I trust here anyways here's a screenshot of the issue and fix or suggestions would be grateful thanks :) [ATTACH=CONFIG]1771[/ATTACH][ATTACH=CONFIG]1772[/ATTACH]

image3.thumb.png.2120c71cbc206cced2a93e9be5366099.png

image4.thumb.png.0e04b69c32e07f45ef85091ea18f30e1.png

Link to comment
Share on other sites

Without seeing the code I can only speculate. For one, your background image appears to one, be fixed and two, be using the background-size: cover; so that will create an illusion of just the elements shrinking in size.

Another thing, and again i can only speculate without seeing the code, i would assume that you have a wrapper div which when you use CTRL + (-) is decreasing in size, therefore your image is actually still technically in the centre of the parent div.

My suggestion is to give your image the following css :

 

.img {
  position: absolute; (or fixed)
  margin: 0 auto;
  top: calc( 50% - *half_img_height*);
}

 

*half_img_height* - replace this with half of your image height.

IF your images are added dynamically, part of an image gallery and it isnt practical to set half the height of each image then jquery will sort this out. You just need to add an onclick event to your galleries navigation arrows:

 

function onGalleryNavClick(){
  var t = $(document).height() - $("gallery img").height() / 2;
  $("#gallery img").css({top: t});
}

 

not overly confident on that piece of jquery, but im pretty sure you can understand what I'm getting at.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...