I have been utilizing Twitter Bootstrap to generate form components as illustrated below. Typically, the 'submit' button should be placed outside of the 'controls' container, however, for my specific layout requirements, I need it to be inside like so:
<div class="control-group">
<div class="controls">
<input type="text" name="email" value="" id="email" class="input-large email" placeholder="email" required="">
<input type="submit" value="submit" name="submit" id="submit" class="btn btn-success">
</div>
</div>
Everything is functioning correctly except for one issue - when I apply the 'error' class to
<div class="control-group error">
, the styling also affects the 'submit' button which is not desired. To prevent this styling conflict, I can modify the bootstrap CSS to include :not([type='submit']) in the following manner:
.control-group.error input**:not([type='submit'])**, .control-group.error select, .control-group.error textarea {
border-color: #B94A48;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
AND
.control-group.error .checkbox, .control-group.error .radio, .control-group.error input**:not([type='submit'])**, .control-group.error select, .control-group.error textarea {
color: #B94A48;
}
Nevertheless, I am contemplating whether there is an alternative method with jQuery to prevent this style from cascading down entirely if the element belongs to a specific type ...
Otherwise, I am considering
- finding a way to instruct a particular element to disregard a specific CSS class
- creating an exact replica with all CSS attributes applied to the element before adding the error class and then substituting it afterwards