O
O
OldSchoolWeb2016-12-06 03:50:34
css
OldSchoolWeb, 2016-12-06 03:50:34

!important not working in sass, what should I do?

I've been suffering for 30 minutes now, if not more. How does !important work in media queries?
Add. there is a div with icons inside it

<div class="social">
<a href="#"><i class="icon vk"></i></a>
<a href="#"><i class="icon instagram"></i></a>
<a href="#"><i class="icon facebook"></i></a>
</div>

At 1200px all icons should be shown, at 991 - facebook is removed, at 480 - all are shown
For the life of me, I can't implement it.
@media only screen and (max-width : 991px)
.social_wrapper
  text-align: center
  a
    padding: 0 !important
    margin: 0
    z-index: 5
    i.facebook
      display: none !important
@media only screen and (min-width : 480px)
.social_wrapper
  text-align: center
  a
    padding: 0 !important
    margin: 0
    z-index: 5
    i.facebook
      display: block !important

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Givandos, 2016-12-06
@OldSchoolWeb

(min-width : 480px)
Fix it to max-width.
You have this block of classes interrupting everything that goes above

O
Oleg, 2016-12-18
@r45her

First stop using important - it's bad practice. If you can't do without them, then something is wrong.
Secondly, it is not necessary to write the same styles in media queries. There you write only the differences.
Thirdly, it's better to stick with either only max-width or min-width. You don't have to mix it all up. It will be easier for you later.
Your code should be written like this:

.social_wrapper
  text-align: center

  a
    padding: 0
    margin: 0
    z-index: 5

@media only screen and (min-width : 480px)
.social_wrapper

  i.facebook
    display: none

@media only screen and (min-width : 991px)
.social_wrapper

  i.facebook
    display: block

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question