0
I created a responsive html page, to run mainly on smartphones. However, on portable devices, in vertical position (standing), the background image does not "resize". Already in the browser, if I decrease the window to the maximum ("imitating" the size of the smartphone), works normally.
Html:
<html>
<head>
<title>hello</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<div class="wrap">
<div class="content">
<div class="logo">
<h1><img src="images/bg2.png"/></h1>
</div>
<center>
<div >
<a href="http://infasstec.com.br/midia"><img src="images/midia_video.png"/></a>
<a href="http://infasstec.com.br/midia"><img src="images/midia_revista.png"/></a>
</div>
</center>
</div>
</div>
</div>
CSS:
@media only screen and (max-width: 768px)
{
.wrap {
width: 80%;
}
.logo img {
width: 315px;
}
}
@media only screen and (max-width: 640px)
{
.wrap {
width: 85%;
}
.logo {
padding: 1% 1% 12% 1%;
}
.buttom {
width: 515px;
}
.logo img {
width: 300px;
}
}
@media only screen and (max-width: 480px)
{
.wrap {
width: 90%;
}
.logo {
padding: 1% 1% 12% 1%;
}
.buttom {
width: 440px;
}
/***/
.logo span {
font-size: 1.6em;
}
.logo img {
width: 270px;
}
}
@media only screen and (max-width: 320px)
{
.wrap {
width: 90%;
}
.logo {
padding: 1% 1% 12% 1%;
}
.buttom {
width: 290px;
}
/***/
.logo span {
font-size: 1.4em;
}
.logo span img {
vertical-align: middle;
}
.logo img {
width: 200px;
}
This is because the browser does this job for you.
– Jorge B.
The problem is in the condition of your
@media
queries. You put the conditiononly screen
, IE, your mobile will disregard these blocks. This is why your desktop browser renders normally and on mobile nothing happens.– Oeslei
@Oeslei thanks for the reply! Can help me on how should the code to work?
– Rene Sá
@Renesá added one more answer showing how to fix the problem. I hope it helps =)
– Oeslei