4
I’m working with the tag <picture>
to use its responsive function and inserting several sizes of the same image into a single object according to the screen resolution by the "media" parameter of the tag <source>
. On Chrome and Mozilla Firefox the results were perfect but on mobile phones and IE11 did not work, they are only using the image in the tag <img>
follows an example of the error:
a#capa-individual{
width: 85%;
position: relative;
display: block;
margin-top: 3%;
margin-bottom: 3%;
margin-right: auto;
margin-left: auto;
box-sizing: border-box;
border: 30px solid rgba(255,0,0,.3);
}
.foto1{
width: 100%;
vertical-align: middle;
text-align: center;
border-radius: 5px;
border: 0px solid rgba(0,0,0,.7);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="erro.css">
</head>
<body>
<a id="capa-individual" href="individual.html">
<picture>
<source class="foto1" srcset="http://thumbs.dreamstime.com/x/lying-male-dalmatian-18553200.jpg" media="(max-width: 480px)">
<source class="foto1" srcset="http://thumbs.dreamstime.com/x/liver-spotted-dalmatian-bitch-17136208.jpg" media="(min-width:481px)">
<img class="foto1" src="http://thumbs.dreamstime.com/x/liver-spotted-dalmatian-bitch-17136208.jpg.jpg" alt="">
</picture>
</a>
</body>
</html>
What didn’t work exactly? What error did you get, didn’t recognize the CSS? Explain it better.
– Guilherme Nascimento
It doesn’t really show errors friends, everything works, but not in the right way, it’s very strange because I’m here testing on various devices, and in no cell phone the "media" function of the <picture> tag is working. The photo that appears on cell phones below 480px is simply the large photo that is in the <img> tag. But on the other hand in Chrome and Mozilla is perfectly functional, when I put the browser to resolution below 480px, soon appears the small photo. Already in IE when I put the browse below 480px, continues the big photo, does not recognize the "media". I do not know what is happening
– GOLX
If it’s a problem with mediaquery then you should put all the css, put something we can play. If you just put snippets and say that the problem is somewhere else it becomes difficult to understand. When I say ERROR I don’t mean ERROR message but to explain how it should work and what is happening instead of expected. Put a code that we can reproduce the problem.
– Guilherme Nascimento
@Guilherme Nascimento Certo, then follows the CSS in its entirety and the Html of the picture tag, it got a little big but the error may be somewhere in the middle of it all, I looked and looked and did not find. I edited them in question. Thanks for the help
– GOLX
When I told you to put an example that we can reproduce, it was for you to take only the necessary parts and try to make the same effect of failure, it became a giant CSS that only you understand, I recommend even if with all attention read this link: http://answall.com/help/mcve makes it easier for you to help us help you out ;)
– Guilherme Nascimento
http://prntscr.com/a5cb71 http://prntscr.com/a5cbaw
– CypherPotato
@Guilherme, thanks for the guidelines, I have read the post and sorry, now I understand how to do, follow the code with the error, I ran on my server and gave the same mistake ever , It is happening the same as on my site. Chrome and mozila the code works perfectly and IE and mobile phones do not work
– GOLX
@GOLX Just two more things, which cell phones occur the problem? On my IE11 I noticed the failure, as soon as I have some time I will try to understand what happened (I am on working hours) ;) - Ps.: It was great the example you added and it was possible to understand the failure.
– Guilherme Nascimento
@RZ-8121 so this is flawed, was for IE11 to appear the first photo, the others he only changed the name, I know it was not so clear, but once I have a time I will edit, his problem is the tag
<source>
which does not work then shows the tag<img>
which is a fallback, if you want you can try to answer, I know the reason for this, the problem is that I still don’t have an alternative solution ;)– Guilherme Nascimento
@Guilherme, thank you, so it doesn’t work on the 2 phones I tested, Samsung Galaxy Duos and ZTE, the two with screen less than 480px.
– GOLX