I am trying to style a SELECT / OPTION boxes using INLINE CSS.
The background-color does not seem to be working:
<option style='bakground-color:red'>text</option>
Basically, I want 3-4 options, but each line to have a separate colored background.
All the CSS examples I have found use external CSS files, or a separate STYLE section above the area I'm working on.
Is it possible to do this inline?
Yes, if you want to give inline style then you can give.
The style is not working in your code because you have a spelling mistake.
You write bakground-color instead of background:color
<select>
<option value="1" style="background-color:yellow">Option 1</option>
<option value="2" style="background-color:orange">Option 2</option>
<option value="3" style="background-color:red">Option 3</option>
<option value="4" style="background-color:green">Option 4</option>
</select>
<option value="aa" style="background: black;">aa</option>
<option value="bb" style="background: blue;">bb</option>
This will show when you select an option from dropdown.
Yes, you can do it inline.
<select>
<option value="green" style="background: green;">green</option>
<option value="cyan" style="background: cyan;">cyan</option>
<option value="yellow" style="background: yellow;">yellow</option>
</select>
Related
i am trying to chaneg the colour of text using twitter-bootstrap but something is wrong it is not working.
here is my code:
<select name="number" '<?=htmlspecialchars($s['number'])?>'td>"
<option><?=htmlspecialchars($s['number'])?></option>
<option class="text-cuccess">Tak</option>
<option class="text-danger">Nie</option>
</select>
.newcolor {
color:red;
}
.newcolor1{
color:green;
}
<select id="select" onchange="this.className=this.options[this.selectedIndex].className">
<option style="color:gray" value="null">select one option</option>
<option value="1" class="newcolor">one</option>
<option value="2" class="newcolor">two</option>
<option value="2" class="newcolor1">two</option>
</select>
I am using Materialize.css library (v 1.0.0), as of 2018 for my project to add the material components. However, I failed to initialize two select boxes with it.
I have two select boxes in my page.
$(function() {
$("#numPagesPaginate").formSelect();
$("#numRatingsEdit").formSelect();
});
<select id="numPagesPaginate" name="numPagesPaginate" data-ng-model="bkCtrl.page.pageSize">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<select id="numRatingsEdit" name="numRatingsEdit" style="display:none">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
However, when I initialize both the select boxes using this only the first one works.
In addition, if I initialize the second selectbox in the script tag elsewhere, the box gets initialized and works, but there is one duplicate selectbox.
Edited: To add this question, I want to tell you that I have read the documentation and the default method. However, no results.
You should follow documentation and initialize globally with one line:
$('select').formSelect();
Just like Serg said, you should follow the documentation properly.
<div class="container">
<div class="row">
<div class="col s6">
<label>Num Pages Paginate</label>
<select id="numPagesPaginate" name="numPagesPaginate" data-ng-model="bkCtrl.page.pageSize">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</div>
<div class="col s6">
<label>Num Ratings Edit</label>
<select id="numRatingsEdit" name="numRatingsEdit">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$('select').formSelect();
});
</script>
I have a problem with IE11 and menu.
When opened the combo, the cursor changes depending on the input behind.
<div>
<select>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
<option value="4">option 4</option>
</select>
<input type="text" value="mouse changes" readonly="readonly" />
</div>
When trying in IE11, the cursor changes in option 2, to the readonly, it select the option if clicking but it seems forbidden option.
I am trying to have datalist list element always visible. As standard after focused lost, the arrow disappears.
I would like to have it always like this:
Here is the plunker: https://plnkr.co/edit/?p=preview
<input list="browsers" name="myBrowser" />
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
<option value="Internet Explorer">
<option value="Opera">
<option value="Safari">
</datalist>
ENVIRONMENT: Angular directive
Any ideas how to achieve it?
Best,
I have got the arrow always visible using css:
input::-webkit-calendar-picker-indicator {
opacity: 100;
}
<input list="browsers" name="myBrowser" />
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
<option value="Internet Explorer">
<option value="Opera">
<option value="Safari">
</datalist>
I am working on a project which uses Materialize css for front end.
Is there any way to get multi select option for dropdown in Materialize css ?
Any piece of info would be helpful.
You only have to add the multiple:
<div class="input-field col s12">
<select multiple>
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label>Materialize Multiple Select</label>
</div>
And then call js:
$(document).ready(function() {
$('select').material_select();
});
jsfiddle
MaterializeCSS's dropdown implementation is not a <select> block. It is just a styled <ul>. Therefore, I don't believe you can take advantage of a multi-select with their implementation. I would use the default <select> block like this:
<select class="browser-default" multiple>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
Note: you must add the browser-default class so that MaterializeCSS doesn't render it.
Since the top and left css properties of the label are set to ~0.8rem each, you can add a specific rule to the li's:
#topics_dropdown li {
height: 3rem;
}