Adding styles to simple_form collection/drop down - css

I'm attempting to override the default simple_form styles for a collection/drop down I have, but am unable to get the width to adjust as my drop down takes up the entire width of the page.
I've add the css provided here, https://github.com/plataformatec/simple_form/wiki/CSS-for-simple_form to my stylesheet and have added a class to be applied to the drop down.
.simple_form div.input {
margin-bottom: 10px;
clear: both; /* Required for Webkit, but not for Gecko */
}
.simple_form label {
float: left;
width: 100px;
text-align: right;
margin: 2px 10px;
}
div.boolean, .simple_form input {
margin-left: 120px;
}
.simple_form input.test {
width: 30px;
}
I used the information from this, Rails simple_form label_html and Add a class to each select options with SimpleForm in attempt to get it work, but while my test class is added, it shows as, class="select optional test". I'm unclear on where the "select optional" is coming from and how to remove it.
In the end, the resulting HTML looks like,
<div class="input select optional f_User">
<label class="select optional" for="f_User">User</label>
<select class="select optional test" id="f_User" name="f[User]">
<option value=""></option>
<option value="15">Shawn</option>
<option value="87">Bob</option>
<option value="88">John</option>
<option value="89">Mary</option>
</select>
</div>
Thanks in advance for your time and assistance.

The classes select and optional seem to be generated by SimpleForm to style the selection box. Taking a look at the code for custom wrappers, each input type has a CSS associated to it based on the input name, i.e. selects have a class="select" etc. The optional class seems to come from the custom options assigned to the specific field such as is the field required or not. If you truly want to remove them, it seems you'll have to monkey patch SimpleForm to achieve this or create a custom wrapped with the css classes you choose.
That said, you could overwrite the width parameter for the "select" class:
.select {
width: 30px;
}

Related

Change the default color picker box

I'm using Angular6 with material-designs. What I'm trying to do is get color input from mat-form-field. For that I used matinput type="color" inside my input tag. My HTML file is as follows,
<div>
<mat-form-field class="form-field">
<mat-label>Color</mat-label>
<input matInput type="color" formControlName="color"required placeholder="Color">
</mat-form-field>
</div>
Then I have added some CSS on it to design the color picker box according to my need,
input[type="color"] {
-webkit-appearance: none;
border: none;
width: 25px;
height: 25px;
float: right;
}
input[type="color"]::-webkit-color-swatch-wrapper {
padding: 0;
}
input[type="color"]::-webkit-color-swatch {
border: none;
}
Now the output what I'm getting is,
Even though this contains black color in default, the form field didn't get any default input. So what I want to do is get the default color box as follows. (To easily understand the requirement I have designed my expectation using photoshop),
You have to add some styles and need some changes in ts file code to display that box
Here is a working example: https://stackblitz.com/edit/angular-tbkqbt

Checkbox not displaying

I am trying to integrate an HTML 5 required checkbox into a form:
<p>
<input class="checkbox" type="checkbox" required name="terms"> By submitting you agree to the processing of your data for the purpose of processing your request/booking.
<br>
<a href="/en/datenschutz.php" target="_blank">
<u>Privacy Policy</u>
</a>
</p>
It is not displaying in a single browser. I haven't had this problem with other sites before, this site is running Bootstrap v2.2.2.
I found some possible solution with labels which didn't work.
Your Style.css file has this rule:
input[type="checkbox"] {
display: none;
}
Delete it and you will see your checkbox.
If you need that rule for whatever reason and you only want to override it for this particular checkbox, then you'll have to add another CSS rule to override it. Obviously, adding an inline style will do the job, but it might be not the best way to go:
<input class="checkbox" type="checkbox" required name="terms" style="display: inline-block;">
Your style.css might contain the appearance css property. This is used to display an element using platform-native styling, based on the operating system's theme. Look up : https://developer.mozilla.org/en-US/docs/Web/CSS/appearance
your code might contain a css rule such as:
input {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
}
if you wanna keep this property and change the checkbox specifically then use :
input[type="checkbox"] {
appearance: checkbox !important;
}
You can use both css.
But here
style="display: inline-block;"
inside input type are override display: none;
input.checkbox {
display: inline-block;
}
/*input[type="checkbox"] {
display: inline-block;
}*/
<p>
<input class="checkbox" type="checkbox" required name="terms">By submitting you agree to the processing of your data for the purpose of processing your request/booking.
</p>
<a href="/en/datenschutz.php" target="_blank">
<u>Privacy Policy</u>
</a>

Changing md-subheader-inner css property

I am trying to remove the padding:16px; property the md-subheader-inner inherits from the md-subheader directive.
The problem is, that when applying another class on my subheader, it seems like i can't change the inner style properties. I have made a codepen trying to show what the problem is here.
Whenever I inspect the element, it doesn't matter which of the two solution I made, the css properties are not updated... I think I am missing something obvious here, but I can't figure out what this is.
Please note that I don't want to use direct modification on md-subheader class because I am using that directive on a lot of places and I don't want any side effect (hence my 'padding-less-inner' class).
Html:
<md-select name="test" multiple="true" ng-model="whatever">
<md-subheader class="md-sticky padding-less-inner">
<md-input-container style="width:100%;padding-left:8px;padding-right: 24px;margin-bottom: 0px;">
<input style="width: calc(100% - 30px);float: right;" ng-model="searchText" class="_md-text" onkeydown="stopPropagation(event)">
</md-input-container>
</md-subheader>
<md-optgroup>
<md-option ng-value="item.id" ng-repeat="item in querySearch()">{{item.name_fr}}</md-option>
</md-optgroup>
CSS:
.padding-less-inner {
.md-subheader-inner {
padding: 0 !important;
}
/*div {
padding: 0 !important;
}*/
}
I made a slight modification to your CSS:
.padding-less-inner .md-subheader-inner {
padding: 0 !important;
}

CSS custom style not taking effect

I have the following HTML
<label class="item formulario item-input item-floating-label" ng-class="{'has-error': registroForm.nombre.$invalid && registroForm.nombre.$dirty, 'valid-lr': registroForm.nombre.$valid && registroForm.nombre.$dirty}">
<span class="input-label">Nombre</span>
<input type="text" placeholder="Nombre" name="nombre" ng-model="vm.nombre"
pattern="[A-Za-z'áéíóú ]+"
ng-minlength="2"
ng-maxlength="30"
required>
</label>
I need to set the following style:
label.item.formulario {
border-style: none none solid none;
border-color: darkblue;
}
But the custom style is not taking effect. If I remove my custom name ".formulario" from my CSS selector and also from the class list in my HTML, the style works perfect BUT it modifies the wholes label with an item class. I just need to modify a specific label, this is the reason what I'm trying to create a custom class.
What's wrong?
Thanks for helping!
I've just tested it here and the style does take effect :
https://jsfiddle.net/8eo8crz1/
label.item.formulario {
border-style: none none solid none;
border-color: darkblue;
}
If you want to have a unique custom style for each label, you'll need to use an id instead of a class (or in addition to the classes you're using).

How to changing the x symbol in a foundation 4 custom checkbox

I am looking for a way to override the checked (x) style in a foundation for custom checkbox
Following the custom forms documentation I have successfully implemented a custom checkbox as follows:
<form class="custom">
<label for="checkbox1">
<input type="checkbox" id="checkbox1" CHECKED />
<span class="custom checkbox checked"></span>Label for checkbox 1
</label>
</form>
This allows me to make css style changes to the look of the checkbox, but I can't find a way te effect the x itself.
if you look in the CSS file used on the page you link to, you will find this part, that is styling the checked checkbox:
form.custom .custom.checkbox.checked:before {
content: "\00d7";
color: #222222;
position: absolute;
top: -50%;
left: 50%;
margin-top: 4px;
margin-left: -5px;
}
changing the content will change the symbol displayed. Hope this helps.
DEMO (provided in Andrey's comment)
change the value of content in your css
form.custom .custom.checkbox.checked:before {
content: "×00d7";}
to
form.custom .custom.checkbox.checked:before {
content: "*";}
or what ever you want
Try this code which would change the "x" to true sign
form.custom .custom.checkbox.checked:before {
content: "\2714";}

Resources