Answer the question
In order to leave comments, you need to log in
CSS @media queries not working?
I’m writing a site on React Js, I started making an adaptive menu, initially the width changed at a width of 600px and then abruptly stopped, now no matter what I write, media at the end of the entire page, "meta viewport ...." and so on is also in index.html , below code:
Menu.js:
import React from 'react';
import './ComponentsStyles/MenuStyles.css';
import { BrowserRouter as Router, Route, Switch, Link } from 'react-router-dom';
export default class Menu extends React.Component {
constructor(props) {
super(props);
this.state = {
}
}
render() {
return (
<>
<header className="menu">
<div className="menu__logo">
<a href="/" className="logo">TRVL <i className="fab fa-typo3"></i></a>
</div>
<div className="menu__links">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/services">Services</a></li>
<li><a href="/products">Products</a></li>
<div id="sign"><a href="/sign-up">SIGN UP</a></div>
</ul>
<i class="fa fa-bars" id="bars"></i>
</div>
</header>
</>
);
}
}
MenuStyles.css:
@import url('https://fonts.googleapis.com/css2?family=Roboto:[email protected]&display=swap');
a, i {
color: #fff;
text-decoration: none;
cursor: pointer;
}
.menu {
width: 1325px;
height: 90px;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
background-color: rgb(45, 33, 33);
}
.logo {
margin-top: 25px;
margin-left: 100px;
font-weight: bold;
font-size: 35px;
display: inline-block;
}
.menu__links {
height: inherit;
float: right;
margin-top: -60px;
}
.menu__links ul li {
display: inline-block;
margin-right: 80px;
font-size: 20px;
}
#sign {
width: 150px;
height: 50px;
border: 2px solid #fff;
box-sizing: border-box;
margin-top: -20px;
margin-right: 50px;
padding-top: 8px;
justify-content: center;
align-items: center;
text-align: center;
display: inline-block;
}
#bars {
display: none;
}
@media screen and (max-width: 600px) {
.menu__links ul li {
display: none;
}
#sign {
display: none;
}
.menu {
width: 600px;
height: 50px;
}
#bars {
display: block;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question