MVC foreach loop styling

Viewed 137

I'm new to the MVC foreach loop styling. How do I style the @item.QuizForHint? I did tried putting #QuizForHint but it's did not work. The @item.QuizForHint will be getting the data from the database.

@foreach (var item in Model){

        <a href="@("#QuizForHint"+i)" id="getAnsHint"  class="btn"  data-toggle="collapse">Quiz Hint</a>
        <div id="@("QuizForHint"+i)" class="collapse">
            @item.QuizForHint

}
1 Answers

The styling you give for class collapse will be applicable of @item.QuizForHint. If you want specific styling apart from the div, then you can place @item.QuizForHint within a span and style the span.

@foreach (var item in Model){

    <a href="@("#QuizForHint"+i)" id="getAnsHint"  class="btn"  data-toggle="collapse">Quiz Hint</a>
    <div id="@("QuizForHint"+i)" class="collapse">
            <span class="stylish">@item.QuizForHint</span>
    </div>

}
Related