search

Home  >  Q&A  >  body text

I added a button but for some reason media queries don't work with it

For some reason the media query doesn't work, it works fine for any other class, I only have problems with this class

I've tried, just removing the screen etc. None are valid

const showImageButton = document.getElementById("show-image-button");
const myImage = document.getElementById("my-image");
showImageButton.addEventListener("click", () => {
  myImage.hidden = !myImage.hidden;
});
button2,
input[type=submit] {
  cursor: pointer;
}

button2,
input,
textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
}

button2 {
  color: currentColor;
  overflow: visible;
  margin: 0
}

button2 {
  border-style: outset;
  line-height: 1.6;
  margin: 0 0 0px;
  text-align: center;
  line-height: 60px;
  max-width: 300px;
  border-radius: 10px;
  display: inline-block;
  text-align: center;
  text-decoration: none;
  position: relative;
  font-weight: 300;
  font-size: .85em;
  width: 100%;
}

So i want to make it to be width 100% on mobile @media only screen {
  .button2 {
    width: 100%;
  }
}
<button2 id="show-image-button">Méret Táblázat</button2>
<img id="my-image" src="https://cdn.shopify.com/s/files/1/2999/5106/files/True-to-Sole-nike-sneaker-sizechart_760x760.jpg?v =1611582903" hidden>

P粉189606269P粉189606269239 days ago440

reply all(1)I'll reply

  • P粉418351692

    P粉4183516922024-03-21 10:32:53

    .button2 - There is a dot which means you are looking for an element with class button2. But in your HTML structure I don't see a class with that name.

    Try the following code, this will find the element with id show-image-button

    @media only screen {
      #show-image-button {
        width: 100%;
      }
    }

    reply
    0
  • Cancelreply