Jump to content
pinchacas

Problem with background-position: center center;

Recommended Posts

Hi everyone!

I have a problem with background-position: center center; on @media only screen and (max-width: 600px)... if background-position: center center; is activated, @media not work for my...

Look at: This work perfectly:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
    background-image: url(fondo.jpg);
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

@media only screen and (max-width: 750px) {
  body {
    background-image: url(750.jpg);
	background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
  }
}
</style>
</head>
<body>

</body>
</html>

But if write background-position: center center; @media not work:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
    background-image: url(fondo.jpg);
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center center;
}

@media only screen and (max-width: 750px) {
  body {
    background-image: url(750.jpg);
	background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
  }
}
</style>
</head>
<body>

</body>
</html>

Why???

Help me please! Thx! 

 

Share this post


Link to post
Share on other sites

What is wrong? You expected center center not to work in media query? You'd  be wrong, it would carry on from position styling from default non media query styling, as does background size, attachment and repeat. If you want to reset to default value use background-position: initial; in media query.

  • Thanks 1

Share this post


Link to post
Share on other sites
18 hours ago, dsonesuk said:

What is wrong? You expected center center not to work in media query? You'd  be wrong, it would carry on from position styling from default non media query styling, as does background size, attachment and repeat. If you want to reset to default value use background-position: initial; in media query.

background-position: initial; on @media work!

U are amazing! Thank u! :)

Share this post


Link to post
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.

Loading...

×
×
  • Create New...