Media query does not work on non-responsive website

Asked

Viewed 620 times

1

Good afternoon everyone, I put media query css3 to work on a fixed width site, but it doesn’t work. It only works on responsive websites?

http://bblender.com.br/clientes/moldin/

@media only screen and (max-width: 959px) {
.tit-h2{margin-left:2px!important;}
#rodape{
width: 104%;
height: 180px;
background: #F68624;
position: absolute;
bottom: 0;}}

Thank you all.

1 answer

3

You must put the METATAG VIEWPORT in the header HEAD page:

<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">

NOTE: You can modify your need by changing the value of the attributes:

  • width - Set a width for the viewport. Values can be in PX or "device-width", which automatically determines a value equal to device screen width.

  • height - Set a height for the viewport. Values can be in PX or "device-height", which automatically determines a value equal to height of device screen.

  • initial-Scale - Sets the viewport’s initial scale.

  • user-Scalable - Sets the possibility for the user to "zoom in" a certain place of the screen. It is activated when the user hits two times with your finger in a place on the screen.

With CSS you only define the styles for each resolution.

To METATAG is to inform the device that the width it should use is the width it appears to have, not that of its resolution which is in PIXELS.

You need to use CSS with MEDIA QUERIES and the METATAG VIEWPORT.

I recommend you start working with relative rather than fixed measures to work with responsive layouts as they are more suitable.

  • solved, this way now. @media only screen and (max-device-width: 959px) { . tit-H2{margin-left:2px! Important;} #footer{ width: 104%; height: 180px; background: #F68624; position: Absolute; bottom: 0; } }

  • If you use it like this (max-device-width: 959px), it will work only on Devices. The monitor is a desktop, not a mobile device. If you put only min-width, max-width, it will suit any type of screen, not just mobiles and so should use the metatag viewport.

  • Vlw for the tip, but it was only in this special case that I needed to fix this detail of the title.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.