[RESOLVED]how to apply css class to particular control only

Hi iam using bootstrap css

I am overriding css class

i want to apply that class to a particular control then the overrided css should be applied

when i apply the same css class to other controls then old css class should be applied

for example

consilder a css class in boot strap

.col-md-2

{

width:16.6666%;

}

it contains the width of 16.6666%

i want to override that css class and apply to lablel class

for that in my page i wrote like this

<style>

.col-md-2

{

width: 14.2222%;

}

</style>

now i want to apply the above overrided class to label so then the label width should be 14.22222%

when i apply same css class to textbox then the textbox width should be old width i.e 16.6666%

how can i do this?

Thanks,

Murali.

Hi try this

<style>

.col-md-2

{

width: 14.2222% !Important;

}

</style>

hi krishna,

the above code will apply to all controls in the page (where i was applied this class)

but I want to apply only to label with width 14.222%

when i apply the same class to other control it should apply 16.6666%

Hi murali,

Use label id instead of class like this

#YourLabelId

{

Same code i mention before

}

Hi,

You can add a new class with: 14.22222%: 

.width14 {
   width: 14.2222%
}

And we can use it like this:

<div class="col-md-2 width14">



</div>

Here you do not need to change any properties on "col-md-2", just add a new class.

Hope this can help

Hi Murali,

Thanks for your post.

murali krishna14

now i want to apply the above overrided class to label so then the label width should be 14.22222%

when i apply same css class to textbox then the textbox width should be old width i.e 16.6666%

As for your problem, I agree with Jannen. Firstly you could apply this css class to both label and textbox, in this situation, the width of label and textbox are 16.6666%. Then you could create a new css for all labels.

Besides, if it is HTML <label> tag rather than label control, you could apply a style to all label tags directly as below.

label {

    width:14.2222%;

}

If you have any question about this issue, please post back.

Best Regards,

Fei Han

Leave a Reply