How to show css div depending upon model value?
Tags: jquery,css,asp.net-mvc-4
Problem :
I'm working on mvc4 project
I have following code html :
<div class="rating">Rating</div> <div class="ratingpoint" title="rating">
<span class="font-icon-star"></span>
<span class="font-icon-star"></span>
<span class="font-icon-star-line"></span>
<span class="font-icon-star-line"></span>
<span class="font-icon-star-line"></span>
</div>
It will show css stars
like below image.
But i want this to be dynamic depending upon my Model.rating values
I tried like following
@foreach (var item in Model.MYTABLE)
{
<div class="rating">Rating</div> <div class="ratingpoint" title="rating">
@if(@item.rating == 2){
<span class="font-icon-star"></span>
<span class="font-icon-star"></span>
}//but how to show the full stars ans below empty stars ?
<span class="font-icon-star-line"></span>
<span class="font-icon-star-line"></span>
<span class="font-icon-star-line"></span>
</div>
}
see image attached example 2 fulled stars and 3 empty
If I have rating value as 4 then i want to show 4 full stars and 1 empty star
Solution :
@for (int i=0; i < item.rating; i++)
{
<span class="font-icon-star"/>
}
@for (int i=item.rating; i < 5; i++)
{
<span class="font-icon-star-line"/>
}
or you can do something like
@for (int i=0; i<5; i++)
if (i < item.rating)
{
<span class="font-icon-star"/>
}
else
{
<span class="font-icon-star-line"/>
}
CSS Howto..
First of all, maybe you should overthink how you generate your table, since you put everything in one row, and then split the single "rows" with <br />... but that's...
The best way i think $("#test span:nth-child(1)").hide(); $("#test span:nth-child(2)").show(); ...
You could use font-size : http://codepen.io/anon/pen/KuJln p:before{ content:'This text has replaced the original.'; font-size:16px;/* if rem not supported */ font-size:1rem; } p{ font-size:0.01px;/* 0+ for ie , yep :) */...
I'm not sure why you are using table in this case, however In order to make <table> and the adjacent <span> stay at the same line you have to change...
The border property goes around the outside of an element, and the clip-path property applies a mask to an element. So, as far as other CSS rules are concerned, you're...
problem solved. I must add pointer-events: none; to the png's div to clickable under div. need detail? Click through a DIV to underlying elements...
they are utf8 codes. there are plenty of sites describing the glyphs for different standard fonts but you can also define your own font set with whatever images you choose...
There's vertical navigation menu tutorials and resources all over the net. I suggest you do some research into the topic. Here's an example tutorial: http://www.noupe.com/css/multilevel-drop-down-navigation-menus-examples-and-tutorials.html Here's an example resource:...
It's a straightforward radial gradient. This should put you on the right track. circle 150px says it's a circular gradient with radius 150px at 25% 33% defines the origin (I've...
Use removeClass and addClass: $(".galImg").click(function () { var image = $(this).attr("rel"); $('#feature').html('<img src="' + image + '"/>'); $('.galImg').removeClass('active'); $(this).addClass('active'); }); DEMO...
You have to reset each individual property back to its default value. It's not great, but it's the only way, given the information you've given us. In your example, you...
Foundation icons use the <i> tags. So you would have something like <i class="fi-social-facebook"></i><a href="http://facebook.com">Facebook</a>. In the zip that you downloaded, there is a preview.html file. Open it in your...
You can't make li element select your radios without using JavaScript. This element is static by design (presentation only). You can use labels to select a radio button, but...
it is not possible in pure css. if you use some css templater language like Sass, you could use @extend for this purpose. however in fact it will just produce...
do this with jquery: $(document).ready(function(){ image_height = $("#myimage").height(); $("#overlay").height(image_height); }); ...
Here is some pure CSS that will not work in IE 6. It involves wrapping a container #outer around both the link and box (#tooltip). Of course, in a real...
Off the top of my head and untested... You could put a border bottom on the header, then have a <span> inside the header which contains the text, put a...
You can still use your own font in an InfoWindow. Simply provide HTML content instead of plain text, and you can style it any way you want with inline CSS...
That is not currently possible, as CSS3 only offers a single functional notation that takes all the values as parameters, rather than a set of properties, for expressing a certain...
Your negative z-index would work if box1 were not positioned, otherwise the subboxes are in a child stacking context, and cannot be positioned under the parent box. http://jsfiddle.net/cPdge/7/ Why is...
If you trying to set the style using css stylesheet, the problem is the inline style applied to the element which gets precedence over the style defined by you. One...
You're using the iframe option right? Are you talking about the width of the website or the height? Because the height can be made dynamic. As for the width, I...
You can override any CSS property by overriding the CSS class or IDs in you own stylesheet with !important attribute if you do not have any access to the original...
Try using rgba as a background. This gives you the option of background opacity. Here's a little calculator I use all the time to get hex to rgba http://hex2rgba.devoth.com/. I'm...
This will work, but only if the two divs are adjacent and b follows a. #a:hover + #b { background: #f00 } <div id="a">Div A</div> <div id="b">Div B</div> If you...
There's an option called :line_comments if you set this to true, Sass will place line numbers in your compiled output. How to set this option depends on how you're using...
There is my best try. I have a little isue that I have corrected in Chrome; but I really don't know even why it works. The CCS is .test {...
Yes, by using :after: .icon:hover:after { content: "Your tooltip"; display: block; position: relative; top: -16px; right: -16px; width: 100px; background: lightblue; } Also check the demo. Please note that all...
Use the Adjacent sibling combinator to choose the input next to the hovered label. label { transform: 56px; font-width: 180px; display: inline-block; text-align: right; text-align: top; } label:hover, label:hover +...
The solution was non-trivial, as my late, great computer science professor used to say. The Slick Carousel (a derivative of the Bootstrap Carousel) uses class="sld-transition-2" (one of three available classes)...