user1870218
user1870218

Reputation: 45

css class not working mvc visual studio

I have declare a class in my site.css file as follows:

.CMenu1 {
  display:inline;
}

Then I have tried to use that class to style my list in Index.cshtml like so:

<ul class="CMenu1">
  <li>Apples</li>
  <li>Bananas</li>
  <li>Lemons</li>
  <li>Oranges</li>
</ul>

However when I run the solution it continues to show the default style for a list, why?

Upvotes: 1

Views: 1319

Answers (3)

Aachal Singh
Aachal Singh

Reputation: 1

class is already a built in property in c#, so in order to make that read you need to put

@class:

<ul @class="CMenu1">
  <li>Apples</li>
  <li>Bananas</li>
  <li>Lemons</li>
  <li>Oranges</li>
</ul>

Upvotes: 0

Nuhman
Nuhman

Reputation: 1270

Anyone looking for a solution to a problem other than what OP have asked for -
Sometimes the class is not added to the Site.css even after rebuilding the project. The problem here is that Site.css is not getting updated in the project even though we have modified it. In this case, clean followed by rebuild or build would do the trick.

Upvotes: 1

ps2goat
ps2goat

Reputation: 8475

You need to apply the css to the <li> elements to make them inline.

.CMenu1 li{
  display:inline;
  }
<ul class="CMenu1">
  <li>Apples</li>
  <li>Bananas</li>
  <li>Lemons</li>
  <li>Oranges</li>
</ul>

Upvotes: 1

Related Questions