Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

@media screen affecting unrelated section

poporacer

New Coder
I have an html file that there is one div that is displayed/hidden based on the screen size and a scrolling text div. When the window reaches the "hidden" threshold, it looks like the CSS for the unrelated scrolling text becomes ignored? What am I missing?
HTML:
<html>
<head>
<style>

* {
  box-sizing: border-box;
}

.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%;}
.col-9 {width: 75%;}
.col-10 {width: 83.33%;}
.col-11 {width: 91.66%;}
.col-12 {width: 100%;}

[class*="col-"] {
  float: left;
  padding: 15px;
}

.row::after {
  content: "";
  clear: both;
  display: table;
}

/* This seems to be the culprit */
@media screen and (max-width: 1000px) {
  div.graphic {
    display: none;
  }

#scroll-container {
  border: 3px solid black;
  border-radius: 5px;
  overflow: hidden;
}

#scroll-text {    
    font-weight: bold;
    font-size: 30px;
    
  /* animation properties */
  -moz-transform: translateX(100%);
  -webkit-transform: translateX(100%);
  transform: translateX(100%);
 
  -moz-animation: my-animation 15s linear infinite;
  -webkit-animation: my-animation 15s linear infinite;
  animation: my-animation 15s linear infinite;
}

/* for Firefox */
@-moz-keyframes my-animation {
  from { -moz-transform: translateX(100%); }
  to { -moz-transform: translateX(-100%); }
}

/* for Chrome */
@-webkit-keyframes my-animation {
  from { -webkit-transform: translateX(100%); }
  to { -webkit-transform: translateX(-100%); }
}

@keyframes my-animation {
  from {
    -moz-transform: translateX(100%);
    -webkit-transform: translateX(100%);
    transform: translateX(100%);
  }
  to {
    -moz-transform: translateX(-50%);
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
  }
}
</style>
</head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<div class="row">
    <div class="col-5 graphic">
        test
    </div>
</div>
<div class="row">
    <div class="col-12">   
        <p>Your message will appear as:</p>
        <div id="scroll-container" >
            <div id="scroll-text">Countdown </div>
        </div> 
        
    </div> 
</div>
</html>
 
Solution
Hey there,
Looks like you forgot to add a closing bracket to the media query. That could possibly be the reason why the CSS rules after it aren't being applied when the window width is more than 1000px.
Hey there,
Looks like you forgot to add a closing bracket to the media query. That could possibly be the reason why the CSS rules after it aren't being applied when the window width is more than 1000px.
 
Solution

New Threads

Buy us a coffee!

Back
Top Bottom