I'm trying to call an ID of my razor element in my CSS class.
Unfortunately, I do not have much experience with Razor.
So, this is my OverviewPageView.razor:
<Card ElementId="newSurveyTitle">
<CardHeader>
<CardTitle>
@localizer["NewSurveyTitle"]
</CardTitle>
</CardHeader>
<CardBody>
<SurveyPreviewView />
</CardBody>
</Card>
This is my CSS:
.newSurveyTitle {
background: #03625e;
}
Does anyone have a hint for me?
CodePudding user response:
Ids are selected with # and you have to use 'id' for that. If you use a dot selector, you would write . The difference is, that an ID has to be unique, a class can be used multiple times.
<Card id="newSurveyTitle">
<CardHeader>
<CardTitle>
@localizer["NewSurveyTitle"]
</CardTitle>
</CardHeader>
<CardBody>
<SurveyPreviewView />
</CardBody>
</Card>
Your css:
#newSurveyTitle{
background: #03625e;
}
CodePudding user response:
You have an element id but your CSS is selecting by class not by id.
Use:
#newSurveyTitle {
background: #03625e;
}