如何解决媒体查询不能覆盖以前的样式?
我目前正在尝试将我代码中较早的样式替换为public class BluePolygon extends JPanel {
private static final long serialVersionUID = 1L;
int x,x1,y,y1;
public BluePolygon() {
addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent me) {
x = me.getX();
y = me.getY();
}
});
addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseDragged(MouseEvent me) {
x1 = me.getX();
y1 = me.getY();
repaint();
}
});
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(new Color(Color.blue.getRed(),Color.blue.getGreen(),Color.blue.getBlue(),60));
int xx[] = { x1,x,x1 };
int yy[] = { y,y1,y1 };
g.fillPolygon(xx,yy,4);
}
public static void main(String args[]) {
SwingUtilities.invokeLater(() -> {
BluePolygon winapp = new BluePolygon();
winapp.setPreferredSize(new Dimension(400,400));
JFrame frame = new JFrame("");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(winapp);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
});
}
}
的填充,但是这样做很难。我试图将节标题仅放在桌面尺寸的中心。
我的原始section-header
是这样的:
section-header
我的媒体查询如下:
.section-header {
padding-left: 10%;
}
我已经使用过@media #{$desktop} {
.section-header {
padding-left: 0;
text-align: center;
}
}
,但是我的导师告诉我要避免使用它。如何覆盖并进行更改?
解决方法
CSS的工作方式多种多样,并且可能变得一团糟,这就是为什么您的导师提到尽可能不使用“!important”的原因。
要注意的一件事是,如果您的版块规则位于媒体查询规则之后,它将覆盖媒体查询规则。
还要考虑特异性。您对定位的要求越具体,该规则就越重要。
快速提问。您是否在Inspect中打开了它,看看它是否还在显示?那么可能存在缓存清除问题等?
如果它在inspect元素中显示,则可能值得检查是否存在具有更高特异性的东西可以覆盖它。
很难在上面找到解决方法,但是在这里不会被接受...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。