我正在尝试定义一个适用于给定样式类(“beveledInput”)的所有输入字段的css规则。例如,在编写此xhml代码时:
class M_ClassAdmin(admin.ModelAdmin):
def get_queryset(self, request):
print("Query SET")
qs = super(M_ClassAdmin, self).get_queryset(request)
if request.user.is_superuser:
return qs
user = User.objects.get(username=request.user.username)
branch = M_Branch.objects.get(HOD = user)
print("Branch_ID_id",branch)
return qs.filter(Branch_ID_id=branch)
def formfield_for_foreignkey(self, db_field, request, **kwargs):
print("I am in func::")
if db_field.name == "Branch_ID":
print("db_field.name",db_field.name)
user = User.objects.get(username=request.user.username)
if not user.is_superuser:
print('user=',user)
branch = M_Branch.objects.get(HOD = user)
print('branch = ',branch)
'''if user=='E0711001':
kwargs["queryset"] = M_Branch.objects.filter(Branch_ID='B101')
#elif user=='E0711002':
else:
kwargs["queryset"] = M_Branch.objects.filter(Branch_ID='B102')'''
#kwargs["queryset"] = M_Branch.objects.filter(Branch_ID=user.branch.id)
kwargs["queryset"] = M_Branch.objects.filter(Branch_Name=branch)
return super(M_ClassAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
fields = ['Branch_ID','Academic_Year','Class_Name']
list_filter = ['Academic_Year','Class_Name']
search_fields = ['Branch_ID','Academic_Year','Class_Name']
list_display = ('Class_Name','Branch_ID','Academic_Year')
admin.site.register(M_Class,M_ClassAdmin)
这是生成的HTML代码
<p:inputText value="#{filtersBean.titleLike}" styleClass="beveledInput" />
到目前为止,我已成功定义了这种css风格,
<input type="text" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all beveledInput" name="_xyz_WAR_xyz_:j_idt5:j_idt33" id="_xyz_WAR_xyz_:j_idt5:j_idt33" role="textbox" aria-disabled="false" aria-readonly="false">
但当然它已应用于所有输入字段,而这不是我真正需要的。
使用.aui input[type="text"],
.aui input[type="search"],
.aui textarea,
.aui
.uneditable-input {
border-radius: 4px;
border-color: #333333;
height: 12.5px;
width: 220px;
}
css类时,如何才能将此样式应用于 ?
答案 0 :(得分:1)
在CSS中使用combination of classes
.aui input[type="text"].beveledInput,
.aui input[type="search"].beveledInput,
.aui textarea.beveledInput,
.aui .uneditable-input.beveledInput {
border-radius: 4px;
border-color: #333333;
height: 12.5px;
width: 220px;
}
答案 1 :(得分:-1)
以此为例:
应用CSS样式
<style>
.inputText{
color: blue !important;
border-radius: 4px;
border-color: #333333;
height: 12.5px;
width: 220px;
}
</style>
和Primefaces组件
<p:inputText styleClass="inputText" />