I need this array of objects in JSON
<script> var galeriaOriginal={"frases":[{"persona":"Bender Bending Rodríguez","frase":"Los robots no tenemos sentimientos... y eso me pone tan triste...","foto":"http://www.topimagenes.net/wp-content/uploads/2015/09/bender-futurama-7-desconfiado.jpg"},{"persona":"Pikachu","frase":"Pika Pika ","foto":"http://st-listas.20minutos.es/images/2011-11/310549/3269993_249px.jpg?1325815180"},{"persona":"Tyrion Lannister","frase":"Cuando doy el dinero para un regalo conjunto digo: Un Lannister siempre paga sus deudas.","foto":"http://i24web.com/wp-content/uploads/2016/05/tyrion-lannister-wallpaper-pack-01-700x525.png"}]}</script>
Show me this way in a JS file via CSS and save it as localstorage
The problem is that I don't know how to do it, I have come to do this:
function mostrarFrases(){
//Cargamos la galeria para mostrarla
galeria=JSON.parse(localStorage.getItem("frases"));
for (var cont=0;cont<galeria.frases.length;cont++)
{
document.write(galeria.frases[cont].frase);
document.write(galeria.frases[cont].persona);
document.write(galeria.frases[cont].foto);
}
}
But this shows me all the text without formatting and instead of the images I only see the path
I'm a newbie, if someone can help me :D
To make it look the way you want you must create an HTML structure and assign CSS styles to it, you could do it in the following way:
long way:
short way:
Another alternative if you don't mind losing compatibility with Internet Explorer is to use an element
template
and generate the elements from the template: