• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Expected LBRACE

Contributor ,
Jun 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

Hi folks.

I keep getting Expected LBRACE after I use @media in my CSS.

Has anyone come across this?

My CSS:

 

@media screen and (max-width: 400px)

.box3 {
float: left;
text-align: center;
height: 300px;
width: 25%;
margin-left: 30px;
margin-top: 20px;
background-color: #FFFFFF;
display: inline-block;
box-shadow: 0px 5px 8px 2px #464a4a;
table-layout: fixed;
border-top: solid 50px;
border-top-color: #494949;
}
.box4 {
text-align: center;
height: 300px;
width: 25%;
margin-left: 30px;
margin-right: 30px;
margin-top: 20px;
background-color: #DFFFFFF;
display: inline-block;
box-shadow: 0px 5px 8px 2px #464a4a;
border-top: solid 50px;
border-top-color: #494949;
}
.box5 {
float: right;
text-align: center;
height: 300px;
width: 25%;
margin-right: 30px;
margin-top: 20px;
background-color: #FFFFFF;
display: inline-block;
box-shadow: 0px 5px 8px 2px #464a4a;
border-top: solid 50px;
border-top-color: #494949;
}

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 21, 2021 Jun 21, 2021

You are missing an opening brace after your media query line and a closing brace at the end of the css contained within it (in red below)...

quote

 

@media screen and (max-width: 400px) {

.box3 {
float: left;
text-align: center;
height: 300px;
width: 25%;
margin-left: 30px;
margin-top: 20px;
background-color: #FFFFFF;
display: inline-block;
box-shadow: 0px 5px 8px 2px #464a4a;
table-layout: fixed;
border-top: solid 50px;
border-top-color: #494949;
}
.box4 {
text-align: center;
height: 300px;
width: 25%;
margin-left: 3

...

Votes

Translate

Translate
Community Expert ,
Jun 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

You are missing an opening brace after your media query line and a closing brace at the end of the css contained within it (in red below)...

quote

 

@media screen and (max-width: 400px) {

.box3 {
float: left;
text-align: center;
height: 300px;
width: 25%;
margin-left: 30px;
margin-top: 20px;
background-color: #FFFFFF;
display: inline-block;
box-shadow: 0px 5px 8px 2px #464a4a;
table-layout: fixed;
border-top: solid 50px;
border-top-color: #494949;
}
.box4 {
text-align: center;
height: 300px;
width: 25%;
margin-left: 30px;
margin-right: 30px;
margin-top: 20px;
background-color: #DFFFFFF;
display: inline-block;
box-shadow: 0px 5px 8px 2px #464a4a;
border-top: solid 50px;
border-top-color: #494949;
}
.box5 {
float: right;
text-align: center;
height: 300px;
width: 25%;
margin-right: 30px;
margin-top: 20px;
background-color: #FFFFFF;
display: inline-block;
box-shadow: 0px 5px 8px 2px #464a4a;
border-top: solid 50px;
border-top-color: #494949;
}

}



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

@media rules must be like this:

 

@media screen and (max-width: 400px)
{
     .box1 {
         //...
     }

     .box2 {
         //...
     }
}

 

Also see: https://www.w3schools.com/cssref/css3_pr_mediaquery.asp

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

As Jon said, CSS media queries have their own set of left & right curly brackets like this:

 

@media {

     selector {rule}

     selector {rule}

}

 

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

LATEST

Thanks for your help Jon and others.

Sooooo obvious when you know how.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines