Search code examples
htmlcssmobilemedia-queries

div css styling not responding to media query for width


I have a div I created that I am using for a subscribe button. This div is responding perfectly to my desktop CSS, but it isn't responding to my commands in my media query.

I have set the width to many different things and it fully takes up the entire page and messes up the rest of my page by making it extend past where the right margin would normal end.

This is the div that I am having issues with.

<div class="subscribebutton" onmouseover="this.style.background='#12BDB8';" onmouseover="this.style.color='white';" onmouseout="this.style.background='transparent';">
    <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">Subscribe</a>
</div>

It is inside of a content wrapper I created..

<div class="newsletter-content">

                <div class="centermailimg"><img src="/images/mailicon.png" alt="mail"></div>
                    <p class="subscribecolortext">Get up-to-date news and special deals sent to your inbox</p><br>
                        <p class="subscribebodytext">We want to hear from you, let us know what we can do to make your experience better!</p>
                    <br><br>
                            <div class="subscribebutton" onmouseover="this.style.background='#12BDB8';" onmouseover="this.style.color='white';" onmouseout="this.style.background='transparent';">
                                <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">Subscribe</a>
                            </div>

                    <div id="light" class="newsletterenvelope"><a class="close" href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a>
                        <form id="newsletterform" action="" method="POST">
                            <span class="spanlargefont"><span class="spancenter">Subscribe To Our Newsletter</span></span>
                            <div class="floatrightinline"><p>Subscribe to our newsletter to receive special promotions and get up to date news about BuyFarBest.</p></div>
                                    <div class="center">
                                        <input class="inputbarcenter" name="name" placeholder="Name" type="text" required><br>
                                        <input class="inputbaremailcenter" name="email" placeholder="Email Address" type="email" required><br><br><br>
                                        <input id="newssubmit" name="submit" type="submit" value="Subscribe" a href = "javascript:void(0)" onclick = "document.getElementById('lightone').style.display='none';document.getElementById('fadeone').style.display='none'"></a>
                                    </div>
                        </form>
                    </div>
                    <div id="fade" class="black_overlay"></div>
                    <div id="lightone" class="newsletterthankyou"><a href = "javascript:void(0)" onclick = "document.getElementById('lightone').style.display='none';document.getElementById('fadeone').style.display='none'">Close</a>
                        <span class="spanlargefont"><span class="spancenter">Thanks for subscribing!</span></span>
                            <p class="center">It won't be long before you start getting awesome deals sent to your inbox.</p>
                    </div>
                    <div id="fadeone" class="black_overlay"></div>

                    <br>

            </div>

This is the normal desktop CSS that works perfect.

.subscribebutton {
width: 350px;
padding: 20px;
border-radius: 15px;
border: 2px solid #12BDB8;
background-color: transparent;
color: #12BDB8;
font-size: 1.5em;
font-weight: bold;
cursor: pointer;
margin: auto;
text-align: center;
}
.subscribebutton a {
    text-decoration: none;
    outline: none;
    color: #12BDB8;
    width: 100%;
}
.subscribebutton a:hover {
    height: 100%;
    width: 100%;
    color: #FFFFFF;
    -webkit-transition: color 300ms ease-in 200ms; /* property duration timing-function delay */
    -moz-transition: color 300ms ease-in 200ms;
    -o-transition: color 300ms ease-in 200ms;
    transition: color 300ms ease-in 200ms;
}
.subscribebutton:hover {
    background-color: #12BDB8;
    color: #FFFFFF;
    -webkit-transition: background 300ms ease-in 200ms; /* property duration timing-function delay */
    -moz-transition: background 300ms ease-in 200ms;
    -o-transition: background 300ms ease-in 200ms;
    transition: background 300ms ease-in 200ms;
}

Then the media query CSS

    .subscribebutton {
    width: 100px;
    padding: 15px;
    border-radius: 15px;
    border: 2px solid #12BDB8;
    background-color: transparent;
    color: #12BDB8;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    margin: auto;
    text-align: center;
}
.subscribebutton a {
    text-decoration: none;
    outline: none;
    color: #12BDB8;

}
.subscribebutton a:hover {
    height: 100%;

    color: #FFFFFF;
    -webkit-transition: color 300ms ease-in 200ms; /* property duration timing-function delay */
    -moz-transition: color 300ms ease-in 200ms;
    -o-transition: color 300ms ease-in 200ms;
    transition: color 300ms ease-in 200ms;
}

Is there something I have over-looked? I've been stuck on this forever.

To see this you can visit the site it is on at buyfarbest.com . It's on the index page.


Solution

  • Your css rule for '.footerbar li a' on line 2392 of your Style.css file is missing a closing brace. That is what is causing some of your media query css to be ignored.

    You have:

    .footerbar li a {
        padding-top: 15px;
        color: #CCCCCC;
        padding: 0px 100px 0px 0px;
        position: relative;
        font-size: 0.7em;
        font-family: Helvetica;
        text-decoration: none;
        outline: none;
    

    It should be:

    .footerbar li a {
        padding-top: 15px;
        color: #CCCCCC;
        padding: 0px 100px 0px 0px;
        position: relative;
        font-size: 0.7em;
        font-family: Helvetica;
        text-decoration: none;
        outline: none;
    }