0.9.0 • Published 5 months ago

@surfsky2000/nocss v0.9.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

About NoCss.js

Write html tag with only attributes. NO css, NO class, NO nodejs... Just like Tailwind.css, rapidly build modern websites without ever leaving your HTML. And more, we don't need to remember any class name anymore. For example:

<div 
   radius='5px' 
   width='100px' height='40px' 
   bgcolor='red' color="white" 
   padding="4px" margin='4px'
   anchor="center" childAnchor="center"
   >
   DIV1
</div>

See more examples : http://surfsky.github.io/NoCss/

Supportted attributes

  • Standard css style attributes, eg. <div width='100px' margin='4px'>
GroupNameDescriptionExample
basiccolorstyle.colorred
basicfontstyle.fontarial
boxboxSizingstyle.boxSizingborder-box, content-box
boxwidthstyle.width100px
boxheightstyle.height100px
boxmarginstyle.margin10px
boxpaddingstyle.padding10px
positionpositionstyle.positionabsolute,fixed,flow...
positiondisplaystyle.display(children)flex,grid...
positiontopstyle.top10px
positionleftstyle.left10px
positionrightstyle.right10px
positionbottomstyle.bottom10px
............
  • Extend attributes. eg. <div radius='4px' anchor='center'>:
GroupNameDescriptionExample
aliaszstyle.zIndex9
aliasradiusstyle.borderRadius12
aliasboxstyle.boxSizingborder-box
aliasbgstyle.backgroundred
aliasbgcolorstyle.backgroundColorred
aliasbgimagestyle.backgroundImage
aliasbgrepeatstyle.backgroundRepeat
aliasbgpositionstyle.backgroundPosition
aliasbgsizestyle.backgroundSize
aliaseventsstyle.pointerEvents
commonnewclassclassList.add(newValue)
commonvisiblevisibiliytrue,false
anchoranchorsetAnchor(ele, newValue, 'absolute')topLeft,top,topRight...
anchorfixanchorsetAnchor(ele, newValue, 'fixed')topLeft,top,topRight...
anchordocksetDock(ele, newValue, 'absolute')top,left,right,bottom,fill
childchildanchorsetChildAnchor(ele, newValue)topLeft,top,topRight...
childchildmarginsetChildStyle(ele, 'margin', newValue)10px
childchildpaddingsetChildStyle(ele, 'padding', newValue)10px
themethemeclsTheme.setThemeCls(ele, newValue)primary,secondary,success...
effectshadowsetShadow(ele, newValue)10px
effecttextshadowsetTextShadow(ele, newValue)10px
effectrotatestyle.transform = rotate(${newValue}deg)30
effectskewstyle.transform = skew(${newValue}deg)30
effectscalestyle.transform = scale(${newValue})1.2
effecthoverbgcolorsetHoverBgColor(ele, newValue);red
effecthovercolorsetHoverTextColor(ele, newValue);red

Install

<script src="./nocss.js"></script>

Examples

Write html tag with attributes

<div 
    radius='5px' 
    width='100px' height='40px' 
    bgcolor='red' color="white" 
    padding="4px" margin='4px'
    anchor="center" childAnchor="center">
    DIV1</div>

Custom Tag

<rect 
    radius='5px' 
    width='100px' height='40px' 
    bgcolor='red' color="white" 
    padding="4px" margin='4px'
    anchor="center" childAnchor="center">
    RECT</rect>

Set attributes/properties by javascript

NoCss.registProperties();  // enject properties for all HTMLElement.
const div = document.createElement('div');
div.width  = '80px';
div.height = '40px';
div.padding = '4px';
div.innerHTML = "DIV2"
div.radius = '5px';
div.bgColor = 'blue';
div.childAnchor = 'center';
document.body.appendChild(div);

Paid services

  • Provide training services.
  • Provide more commercial controls.
  • Provide customized versions that are compatible with third-party libraries.
  • Contact me by wechat: surfsky
0.9.0

5 months ago