css - dynamic JSP background color -
i have html form submitted jsp. form has input specifies background color preference. on jsp page, trying use background color specified user, or, if not enter anything, use color specified in css file. possible?
i have in jsp specifies location of css file, know can css background color, if user specifies color, want 'ignore' that, , use color chose.
is possible?
you load default css via <link href...>
, , add overrides in <style>
block on page. since styles defined on style
block have precedence on other ones override default values. can see more how css "cascades" styles on w3c specs.
try in <head>
<link href="default.css" media="all" rel="stylesheet" /> <style> /* define custom css user here */ body{ background-color: <% ... %>; } </style>
i suppose there many ways of producing correct output in jsp, using jstl core if tag following:
<style> /* define custom css user here */ body{ <core:if test="${param.backgroundcolor!= null}"> background-color: <%=request.getparameter("backgroundcolor")%> </core:if> } </style>
this way if user has selected custom background-color
h1
element, override default.
Comments
Post a Comment