html – Como trocar uma imagem dentro de uma div pelo javascript

Preciso alterar a imagem dentro da div se a largura da tela for menor ou igual a 991.

Eu fiz o código abaixo, mas não está funcionando.

Preciso saber onde estou errando e como corrigir.

html

  <div class="dImg">
     <img class="dImg2" src="assets/img/path.svg">
  </div>

javascript

$(window).load(function teste() {
    var tamanho = window.innerWidth;
    if (tamanho <= 991) {
        $(".dImg2").remove();
        $(".dImg").append("<img src="
            assets / img / path991.svg ">");
    };
});

Também teste com esse js

$(window).load(function teste() {
    var tamanho = window.innerWidth;

    if (tamanho <= 991) {
        $('.dImg2').attr("src").replace("assets/img/path.svg", "assets/img/path991.svg");
    };
});

Obrigada 🙂

html – Coloco uma imagem no meu link com bootstrap, e a imagem não carrega de jeito nenhum… Alguém sabe o que está acontecendo?

<nav class="navbar navbar-light bg-light">
    <a class="navbar-brand" href="/blog">
        <img src="../../static/blog/images/logos/FDG.svg" width="30" height="30" alt="" loading="lazy">
    </a>
</nav>

Ta aí o código, ja tentei colocar um botão, não vai, não chega nem a aparecer um espaço clicável na tela…

html – Adding a dropdown box with hover in CSS

I’m trying to practice on Html-CSS. I used some grids and I created a simple design, I try to add a hover under the MUSIC Button, like a dropdown in the navigation bar.

<!DOCTYPE html>
<html>
<head>
    <link href="linkin park web page.css" type="text/css" rel="stylesheet">
     
</head>
<body>
    <div id="page">
        <div id="logo">
            <img src="logo.jpeg" alt="logo" height="50px" width="50px">
        </div>
            <div class="topwriting">LINKIN PARK </div> 
            <div class="list">
        
                        
                <div><a class="main" href="Home.html">HOME</a></div>
                <div><a  class="main" href="Home.html" >ABOUT</a></div>               
                <div class="button"><button class="buttonview">MUSIC</button>
                        <div class="dropdown_content">
                            <a id= altbutton1> albums</a>
                            <a id= altbutton2> singles</a>
                            <a id= altbutton3> others</a>
                        </div>
                   
                    
               </div>
                <div><a class="main" href="Home.html">VIDEOS</a></div>
                <div><a  class="main" href="Home.html">CONTACT</a></div>
            
        </div>
        <div>
            <!--<img id="p1" src="photos/f1.jpeg" alt="photo 1"  height="220px" width="320px">
            <img id="p2" src="photos/f2.jpg" alt="photo 2" height="220px" width="320px">
            <img id="p3" src="photos/f3.jpg" alt="photo 3" height="220px" width="320px">
            <img id="p4" src="photos/f5.jpg" alt="photo 4" height="220px" width="320px">
            <img id="p5" src="photos/f6.jpg" alt="photo 5" height="220px" width="320px">
            <img id="p6" src="photos/f7.jpg" alt="photo 6" height="220px" width="320px" >
            -->
        </div>
        <div><p id="lastquote">  “The hardest part of ending is starting again.” </p></div>
    </div>
</body>



</html>
body{
    background-image: url("album covers.jpg");
    color: white;
    
       
}
#page{
    max-width: 900px;
    min-width: 999px;
    padding: 20px;
    margin: auto;
    background-color: black;
    border-radius: 10px;
    display: grid;
    grid-template-rows: 2fr, 2fr,  15fr, 2fr; 
    font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif ;

}
.list{
    border: white solid 1px;
    display: grid;
    grid-template-columns: repeat(5,1fr);
    text-align: center; 
    overflow: hidden;   
}
.list>div>a , .button{
    text-decoration: none;
    font-size: 2em;
    color: white;
    
}

.topwriting{
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif ;
color: white;
font-size: 50px;
letter-spacing: 0.0001em;
text-align: center;
padding-top: 0em;
border-width: 2px;
border: white;
border-style: none;
margin-top: 0em;

}
#logo{
    
    border-width: 2px;
    border: white;
    border-style: solid;
    margin-bottom: 0em;
    width: 5% ;
    margin: 10px auto 25px auto ;
}
.button{
    
    position: relative;
    float: left;
    overflow: hidden;
}
.buttonview{
    text-decoration: none;
    background-color: inherit;
    color: inherit;
    border: none;
    font-size: inherit;
    font-family: inherit;
}
.buttonview:hover{
    background-color: cadetblue;
}
.dropdown_content{
    display: none;
    position: absolute;
    background-color: cadetblue;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
}

.button>div>a{
    display: block;
    padding: 12px 16px;
    float: none;
    text-decoration: none;
    text-align: left;
}

.button>div>div>a:hover{
background-color: red;
}
.button:hover .dropdown_content{
    display: block;
}
#lastquote{
    font-family: 'Times New Roman', Times, serif;
    font-size: 20px;
    font-style: italic;
    
    text-align: center;
    letter-spacing: 0,05px;
}

dropdown-content must show up under the MUSIC button but nothing show up or all dropdown-content stay right under there. How can I add a dropdown box under the MUSIC with hover ? What is wrong with my code?

html – div with height of body

I’ve currently came across with this problem which required me to have div with height of body. so i’ve googled it and there was solution which required body with 100% height and child div with 100% height. it did work but in responsive layout div didn’t have height of body because of overflow-y. but when i removed 100% height value of div (#root) and set it to initial it did work. why?

enter image description here
enter image description here

this is scroll

html – ¿Por qué el texto me sale en 2 filas y 2 columnas en lugar de 1 fila con 4 columnas?

Tengo el código HTML

* {box-sizing: border-box;}
      /* Create four equal columns that floats next to each other */
      .column {
        float: left;
        width: 25%;
        padding: 5px;
      }
      /* Clear floats after the columns */
      .row:after {
        content: "";
        display: table;
        clear: both;
      }
      .center {
        display: block;
        margin-left: auto;
        margin-right: auto;
        width: 50%;
      }
      .t1{
       color:#624662;
       text-align: center;
       font-size: 14px;
      }
      .t2{
       color:#fc8e04;
       text-align: center;
       font-size: 35px;
      }
      img{
        horizontal-align: middle;
     }
        
      /* Responsive layout - when the screen is less than 600px wide, make the three columns stack on top of each other instead of next to each other */
@media screen and (max-width: 600px) {
  .column {
    width: 100%;
  }
}
<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
   
  </head>
  <body>
    <br>
       <div class="row">
         <div class="column">
           <div style="text-align: center">
          <img src="https://es.stackoverflow.com/URL" class="middle" width="50" height="50"></div>
           <div class="t1"><b>Plazas de movilidad</b></div>
           <div class="t2">+350</div>
           <div class="t1">Más de 350 plazas anuales de movilidad internacional.</div>
         </div>
         
         <div class="column">
           <div style="text-align: center">
           <img src="https://es.stackoverflow.com/URL" class="middle" width="50" height="50"></div>
           <div class="t1"><b>Países</b></div>
           <div class="t2">37</div>
           <div class="t1">37 países con más de 120 universidades colaboradoras. </div>
         </div>
         
         <div class="column">
           <div style="text-align: center">
           <img src="https://es.stackoverflow.com/URL" class="middle" width="50" height="50"></div>
           <div class="t1"><b>Dobles titulaciones</b></div>
           <div class="t2">26</div>
           <div class="t1">Posibilidad de obtener dobles titulaciones en 26 universidades.</div>
         </div>
         
         <div class="column">
         <div style="text-align: center">
         <img src="https://es.stackoverflow.com/URL" class="middle" width="35" height="40"></div>
           <div class="t1"><b>Porcentaje</b></div>
           <div class="t2">+80%</div>
           <div class="t1">Más del 80% de los alumnos se van a su primera opción.</div>
         </div>
           
         </div>
    </body>
</html>

La idea es que aparezcan en 1 sola fila con 4 columnas, pero cuando lo incluyo en mi web me aparecen en 2 filas y 2 columnas.
introducir la descripción de la imagen aquí

¿Alguien sabe cómo puedo hacer para que aparezca correctamente? He probado el código en páginas externas y me aparece así, que es como lo quiero, pero no logro que en mi web salga igual.
introducir la descripción de la imagen aquí

¿Qué tengo que hacer para que me salga como en la foto superior? ¿Tiene algo que ver con el CSS o con el tamaño del texto?
No sé cómo modificarlo. No me deja modificar el width ni el padding de las preguntas, ¿puede ser un problema de espacio?

html – Is it perfect way to write code using BEM structure?

Guy, This is my code structure using BEM Structure. I need your help to improve my code structure please review this template and let me know if anything is incorrect.

<!-- header -->
<header class="header">
    <!-- header top -->
    <div class="header__top pt-15 pb-15">
        <div class="container d-flex align-items-center justify-content-between">
            <div class="header__top--left">
                <div class="header-logo">
                    <a href="index.html">Logo</a>
                </div>
            </div>
            <div class="header__top--right">
                <div class="header-account d-flex align-items-center">
                    <div class="header-account__button">
                        <a href="#" class="btn btn-custom">Login</a>
                        <a href="#" class="btn btn-custom">Signup</a>
                    </div>
                    <div class="header-account__cart">
                        <a href="#"><i class="fas fa-shopping-cart"></i><span class="badge">3</span></a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- header bottom -->
    <div class="header__bottom">
        <div class="container">
            <nav class="main-nav">
                <li><a href="#">All</a></li>
                <li><a href="#">Men</a></li>
                <li><a href="#">Women</a></li>
                <li><a href="#">Boys</a></li>
                <li><a href="#">Girls</a></li>
                <li><a href="#">Babies</a></li>
                <li><a href="#">Offer Zone</a></li>
            </nav>
        </div>
    </div>
</header>
</body>

embed – Why does my custom html code (for a donation form) appear in a preview but not in the published post?

I have tried to add the following code using a ‘Custom html’ block (to embed a GiveNow donation form). It shows as a preview on the page however when I attempt to view it on the live website, it is not visible:

<div style="padding:1px;max-width: 700px"><iframe class="gn-iframe" src="https://www.givenow.com.au/embed/Y2F1c2VpZD04MTImZG9tYWluPWxpZmUtZ2F0ZS5vcmcmdG9rZW49ODEyOjZhMGFhNmQyYzZiZTM2ZTk%3D" height="870" style="width: 100%" frameborder="0"></iframe></div>

I have read through other help responses to similar issues but can’t figure out what I’m doing wrong.

Thanks in advance, Lauryn

html – Save all input from form into txt and add text

I am trying to save my input from HTML form. It seems easy, but I am stuck at the very beginning.

By far, this is my code:

<!DOCTYPE html>
<html>
<head>
<style>
form * {
  display: block;
  margin: 10px;
}
</style>

<script language="Javascript" >
function download(filename, text1, text2, text3) {
  var pom = document.createElement('a');
  
  pom.setAttribute('href', 'data:text1/plain;charset=utf-8,' + encodeURIComponent(text1));
  pom.setAttribute('href', 'data:text2/plain;charset=utf-8,' + encodeURIComponent(text2));
  pom.setAttribute('href', 'data:text3/plain;charset=utf-8,' + encodeURIComponent(text3));
  
  pom.setAttribute('download', filename);
  pom.style.display = 'none';
  document.body.appendChild(pom);

  pom.click();

  document.body.removeChild(pom);
}
</script>

</head>

<body>

<form onsubmit="download(this('name').value, this('userInfo').value, this('otherInfo').value, this('text').value)">
  <div>
  <label for="name">File Name</label>
  <input type="text" name="name" value="test.txt">
  </div>
  <div>
  <label for="userInfo">User Info</label>
  <input type="text" name="userInfo" value="Name Surname">
  </div>
  <div>
  <label for="userInfo">Other Info</label>
  <input type="text" name="otherInfo" value="95">
  </div>
  <div>
  <label for="userInfo">Text area</label>
  <textarea rows=3 cols=50 name="text">Insert your text here</textarea>
  </div>
  
  <div>
  <input type="submit" value="Download">
  <div>
</form>

</body>
</html>

I am having trouble in multiple steps:

  1. The .txt output is:
Insert your text here
  1. I would like to add some extra text between all the input data

How can I do that?

So, my example input/form would be:

File name
example.txt

User Info
Name Surname

Other Info 
95

and, if I am lucky enough, my desired output would be the file example.txt containing:

Hello, this is my example text page!
-----------------------------------------
User Info:            (comp1)      Name Surname
-----------------------------------------

°Information

-----------------------------------------
Other Info:           (numb)       95
-----------------------------------------

This file was generated through HTML and Javascript.
Modify it or recompile it...

html – Como aceitar um valor submit de um radioButton num form?

Tenho este form com RadioButtons numa view e depois coloco um botão submit que submete a resposta selecionada. A ‘RespostaDoJogador’ é uma propriedade de um Model chamado Jogo. E o objetivo seria, quando seleciono uma opção e a submeto, a propriedade ‘Resposta do Jogador’ assume aquele valor do RadioButton selecionado. O que estarei a fazer mal? :

@if (Model.Casa40 == true)

{

@Model.PerguntaEscolhida

    @if (@Model.PerguntaEscolhida == "Qual destes frutos é vermelho?")

    {
        <input type="radio" id="banana" name="opcao" value="banana" onclick="this.RespostaDoJogador.submit();">

        <label for="banana">Banana</label><br>

        <input type="radio" id="laranja" name="opcao" value="laranja" onclick="this.RespostaDoJogador.submit();">

        <label for="laranja">Laranja</label><br>

        <input type="radio" id="melao" name="opcao" value="melao" onclick="this.RespostaDoJogador.submit();">

        <label for="melao">Melão</label>

        <input type="radio" id="tomate" name="opcao" value="tomate" onclick="this.RespostaDoJogador.submit();">

        <label for="tomate">Tomate</label>
        <button type="submit" form="form1" value="Submit">submit</button>
    }


    @if (@Model.PerguntaEscolhida == "Qual destes alimentos é um fruto?")

    {
        <input type="radio" id="banana" name="opcaoo" value="banana" onclick="this.RespostaDoJogador.submit();">

        <label for="banana">Banana</label><br>

        <input type="radio" id="carapau" name="opcaoo" value="carapau" onclick="this.RespostaDoJogador.submit();">

        <label for="carapau">Carapau</label><br>

        <input type="radio" id="francesinha" name="opcaoo" value="francesinha" onclick="this.RespostaDoJogador.submit();">

        <label for="francesinha">Francesinha</label>

        <input type="radio" id="bifana" name="opcaoo" value="bifana" onclick="this.RespostaDoJogador.submit();">

        <label for="bifana">Bifana</label>
        <button type="submit" form="form1" value="submit">Submit</button>
    }

   

@if (@Model.PerguntaEscolhida == “Qual destes alimentos é peixe?”)

    {
        <input type="radio" id="morango" name="gender" value="morango" onclick="this.RespostaDoJogador.submit();">

        <label for="morango">Morango</label><br>

        <input type="radio" id="leitao" name="gender" value="leitao" onclick="this.RespostaDoJogador.submit();">

        <label for="leitao">Leitão</label><br>

        <input type="radio" id="sardinha" name="gender" value="sardinha" onclick="this.RespostaDoJogador.submit();">

        <label for="sardinha">Sardinha</label>

        <input type="radio" id="lasanha" name="gender" value="lasanha" onclick="this.RespostaDoJogador.submit();">

        <label for="lasanha">Lasanha</label>
        <button type="submit" form="form1" value="submit">Submit</button>
    }
</form>

}

html – How to avoid that H1 tag is used for SEO, “fake” H1 with CSS

What is the best and easiest way to provide something like the H1 tag but in a way that it doesn’t affect google rankings? Our homepage sometimes is used for advertisement, this should be in the H1 which is normally used for the default content that describes the company.

But we don’t want that search engines list us with these ads. Do we have to replace the H1 with something else, for example CSS with big font and bold or is there another way to avoid it?