我的问题是我似乎无法让我的CSS影响到selected-js呈现的内容。选定的js通过适当的功能呈现良好(尽管在没有CSS的情况下看起来很奇怪),并且CSS可以影响选定的js周围的其他对象。该样式可在测试html文件中使用。
HTML
<!DOCTYPE html>
<html>
<body>
<select id="ingredient_select" data-placeholder="Choose a Food" class="chosen-select" multiple>
<option>Test</option>
<option>Test</option>
<option>Test</option>
</select>
</body>
</html>
CSS
h1 {
color: blue;
}
.chosen-select {
width: 100%;
}
.chosen-container {
display: inline-block;
font-size: 14px;
position: relative;
vertical-align: middle;
}
.chosen-container .chosen-drop {
background: #fff;
border: 1px solid #ccc;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
-webkit-box-shadow: 0 8px 8px rgba(0, 0, 0, 0.25);
box-shadow: 0 8px 8px rgba(0, 0, 0, 0.25);
margin-top: -1px;
position: absolute;
top: 100%;
left: -9000px;
z-index: 1060;
}
.chosen-container.chosen-with-drop .chosen-drop {
left: 0;
right: 0;
}
.chosen-container .chosen-results {
color: #555555;
margin: 0 4px 4px 0;
max-height: 240px;
padding: 0 0 0 4px;
position: relative;
overflow-x: hidden;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.chosen-container .chosen-results li {
display: none;
line-height: 1.42857;
list-style: none;
margin: 0;
padding: 5px 6px;
}
.chosen-container .chosen-results li em {
background: #feffde;
font-style: normal;
}
.chosen-container .chosen-results li.group-result {
display: list-item;
cursor: default;
color: #999;
font-weight: bold;
}
.chosen-container .chosen-results li.group-option {
padding-left: 15px;
}
.chosen-container .chosen-results li.active-result {
cursor: pointer;
display: list-item;
}
.chosen-container .chosen-results li.highlighted {
background-color: #337ab7;
background-image: none;
color: white;
}
.chosen-container .chosen-results li.highlighted em {
background: transparent;
}
.chosen-container .chosen-results li.disabled-result {
display: list-item;
color: #777777;
}
.chosen-container .chosen-results .no-results {
background: #eeeeee;
display: list-item;
}
.chosen-container .chosen-results-scroll {
background: white;
margin: 0 4px;
position: absolute;
text-align: center;
width: 321px;
z-index: 1;
}
.chosen-container-multi .chosen-choices {
background-color: #fff;
border: 1px solid #ccc;
border-top-right-radius: 4px;
border-top-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
cursor: text;
height: auto !important;
height: 1%;
margin: 0;
overflow: hidden;
padding: 0;
position: relative;
}
.chosen-container-multi .chosen-choices li {
float: left;
list-style: none;
}
.chosen-container-multi .chosen-choices .search-field {
margin: 0;
padding: 0;
white-space: nowrap;
}
.chosen-container-multi .chosen-choices .search-field input[type="text"] {
background: transparent !important;
border: 0 !important;
-webkit-box-shadow: none;
box-shadow: none;
color: #555555;
height: 32px;
margin: 0;
padding: 4px;
outline: 0;
}
.chosen-container-multi .chosen-choices .search-choice {
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
background-color: #eeeeee;
border: 1px solid #ccc;
border-top-right-radius: 4px;
border-top-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 100%);
background-image: -o-linear-gradient(top, white 0%, #eeeeee 100%);
background-image: linear-gradient(to bottom, white 0%, #eeeeee 100%);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0);
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
color: #333333;
cursor: default;
line-height: 13px;
margin: 6px 0 3px 5px;
padding: 3px 20px 3px 5px;
position: relative;
}
.chosen-container-multi .chosen-choices .search-choice .search-choice-close {
background: url(https://dcmmusw2fcium.cloudfront.net/static/images/chosen/chosen-sprite.png) right top no-repeat;
display: block;
height: 10px;
position: absolute;
right: 4px;
top: 5px;
width: 12px;
cursor: pointer;
}
以及必要的样式Typescript声明
@Component({
selector: 'jhi-recipe-search',
templateUrl: './recipe-search.component.html',
styleUrls: ['recipe-search.css']
})