Yevgeniy Bagackiy Yevgeniy Bagackiy - 29 days ago 15
CSS Question

Cannot set style for label inside css

I have a html code:

<div class="projLeader">
<div class="ui-widget-content">
<label>Captain:</label>
<ol>
<li class="placeholder" name="projLeader"><div class="adding">Drop Here</div></li>
<li class="dropClass" name="projLeader" <?php if (isset($projLeader)) echo 'value="'.$projLeader.'"' ?>><?php echo "<span class='closer'>x</span>".$projLeader.""?></li>
<input type="hidden" name="projLeader" class="hiddenListInput1" />
</ol>
</div>
</div>


I want to add css style:

.projLeader label
{
margin-left:25% !important;
}


But it does not work. if i put it inside label in html code it works:

<label style:'margin-left:25%;'>Captain:</label>


I have style for
.projLeader
:

.projLeader
{
float:left;
margin:3px;
width:30%;
}


And it works, so why it does not work with label?

Answer

As far as it looks this will probably work

.projLeader label
{
    margin-left: 25% !important;
}

but consider this if .ui-widget-content has it's own selector for label in its CSS then your style will be denied. To give your style priority add the exact same selector .ui-widget-content Try to use inspect element to see what it used as a selector used and put your override CSS below that library.

.projLeader .ui-widget-content label
{
    margin-left: 25% !important;
}

Hope that helps