css3 - CSS - Is it possible to assign the same specification of a class to an id -
i working application auto-generates html pages , need write css files these pages. want reuse several classes (generated jquery-ui theme), i can not change html element.
so, possible assign same specification of class id?
if possible, create mapping between classes , ids.
example:
<html> <head><style> #charlieid { /* want #charlie identical .alphaclass */ /* assume can not change html (it auto generated application)*/ } .alphaclass { font-size: small; color: lime; } .betaclass { font-size: medium; color: blue; } </style></head> <body> <p class="alphaclass">alpha</p> <p class="betaclass">beta</p> <p id="charlieid" class="charlieclass">charlie</p> <body></html>
i have hundreds (maybe thousand) ids manage in whole application not in 1 single page. so, have total freedom when comes css, therefore can break down in several css files (one file each page) control ids , main css classes.
afaik there no way "inherit" existing class's style in plain css.
if client-side scripting acceptable, can dynamically add classes. jquery example:
$(document).ready(function() {$('#charlieid').addclass('alphaclass');});
note if do have ability change existing css have misinterpreted question. in case don't have explicitly rewrite style, can use comma-separated list:
#charlieid, .alphaclass { font-size: small; color: lime; }
since indeed are able edit css, can higher-level language, example less. in less, do:
.alphaclass { font-size: small; color: lime; } #charlieid { .alphaclass }
Comments
Post a Comment